Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
23ef0e20
Unverified
Commit
23ef0e20
authored
8 months ago
by
Chris Truter
Committed by
GitHub
8 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Be explicit about truncating characters versus bytes (#44876)
parent
074c78de
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/driver.clj
+2
-2
2 additions, 2 deletions
src/metabase/driver.clj
src/metabase/upload.clj
+6
-4
6 additions, 4 deletions
src/metabase/upload.clj
with
8 additions
and
6 deletions
src/metabase/driver.clj
+
2
−
2
View file @
23ef0e20
...
...
@@ -958,13 +958,13 @@
nil
)
(
defmulti
table-name-length-limit
"Return the maximum number of
charac
te
r
s allowed in a table name, or `nil` if there is no limit."
"Return the maximum number of
by
tes allowed in a table name, or `nil` if there is no limit."
{
:changelog-test/ignore
true,
:added
"0.47.0"
,
:arglists
'
([
driver
])}
dispatch-on-initialized-driver
:hierarchy
#
'hierarchy
)
(
defmulti
column-name-length-limit
"Return the maximum number of
charac
te
r
s allowed in a column name, or `nil` if there is no limit."
"Return the maximum number of
by
tes allowed in a column name, or `nil` if there is no limit."
{
:changelog-test/ignore
true,
:added
"0.49.19"
,
:arglists
'
([
driver
])}
dispatch-on-initialized-driver
:hierarchy
#
'hierarchy
)
...
...
This diff is collapsed.
Click to expand it.
src/metabase/upload.clj
+
6
−
4
View file @
23ef0e20
...
...
@@ -41,22 +41,22 @@
(
set!
*warn-on-reflection*
true
)
(
def
^
:private
max-field-name-
length
"This tracks the size of the metabase_field.name field"
(
def
^
:private
max-field-name-
bytes
"This tracks the size of the metabase_field.name field
, in bytes.
"
254
)
(
def
^
:private
min-safe
(
fnil
min
Long/MAX_VALUE
Long/MAX_VALUE
))
(
defn-
max-column-bytes
[
driver
]
(
let
[
column-limit
(
some->
driver
driver/column-name-length-limit
)]
(
min-safe
column-limit
max-field-name-
length
)))
(
min-safe
column-limit
max-field-name-
bytes
)))
(
defn-
normalize-column-name
[
driver
raw-name
]
(
if
(
str/blank?
raw-name
)
"unnamed_column"
(
u/slugify
(
str/trim
raw-name
)
;; since
normaliz
ed names contain only ASCII characters, we can conflate bytes and length here.
;; since
slugifi
ed names contain only ASCII characters, we can conflate bytes and length here.
{
:max-length
(
max-column-bytes
driver
)})))
(
def
auto-pk-column-name
...
...
@@ -108,6 +108,8 @@
[
driver
table-name
]
(
let
[
time-format
"_yyyyMMddHHmmss"
slugified-name
(
or
(
u/slugify
table-name
)
""
)
;; since both the time-format and the slugified-name contain only ASCII characters, we can behave as if
;; [[driver/table-name-length-limit]] were defining a length in characters.
max-length
(
-
(
driver/table-name-length-limit
driver
)
(
count
time-format
))
acceptable-length
(
min
(
count
slugified-name
)
max-length
)
truncated-name-without-time
(
subs
slugified-name
0
acceptable-length
)]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment