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
8e0c7765
Unverified
Commit
8e0c7765
authored
1 year ago
by
metamben
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Handle rubbish in mongodb versionArray (#30879)
Fixes #29678.
parent
ad6f5c0d
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
modules/drivers/mongo/src/metabase/driver/mongo.clj
+7
-2
7 additions, 2 deletions
modules/drivers/mongo/src/metabase/driver/mongo.clj
modules/drivers/mongo/test/metabase/driver/mongo_test.clj
+17
-0
17 additions, 0 deletions
modules/drivers/mongo/test/metabase/driver/mongo_test.clj
with
24 additions
and
2 deletions
modules/drivers/mongo/src/metabase/driver/mongo.clj
+
7
−
2
View file @
8e0c7765
...
...
@@ -183,9 +183,14 @@
(
defmethod
driver/dbms-version
:mongo
[
_
database
]
(
with-mongo-connection
[
^
com.mongodb.DB
conn
database
]
(
let
[
build-info
(
mg/command
conn
{
:buildInfo
1
})]
(
let
[
build-info
(
mg/command
conn
{
:buildInfo
1
})
version-array
(
get
build-info
"versionArray"
)
sanitized-version-array
(
into
[]
(
take-while
nat-int?
)
version-array
)]
(
when
(
not=
(
take
3
version-array
)
(
take
3
sanitized-version-array
))
(
log/warnf
"sanitizing versionArray %s results in %s, losing information"
version-array
sanitized-version-array
))
{
:version
(
get
build-info
"version"
)
:semantic-version
(
get
build-info
"
version
A
rray
"
)
})))
:semantic-version
sanitized-
version
-a
rray
})))
(
defmethod
driver/describe-database
:mongo
[
_
database
]
...
...
This diff is collapsed.
Click to expand it.
modules/drivers/mongo/test/metabase/driver/mongo_test.clj
+
17
−
0
View file @
8e0c7765
...
...
@@ -21,6 +21,7 @@
[
metabase.test.data.mongo
:as
tdm
]
[
metabase.util.log
:as
log
]
[
monger.collection
:as
mcoll
]
[
monger.core
:as
mg
]
[
taoensso.nippy
:as
nippy
]
[
toucan2.core
:as
t2
])
(
:import
org.bson.types.ObjectId
))
...
...
@@ -488,3 +489,19 @@
(
mt/rows
(
mt/run-mbql-query
bird_species
{
:filter
[
:contains
$bird_species._
"nett"
]}))))))))
(
deftest
strange-versionArray-test
(
mt/test-driver
:mongo
(
testing
"Negative values in versionArray are ignored (#29678)"
(
with-redefs
[
mg/command
(
constantly
{
"version"
"4.0.28-23"
"versionArray"
[
4
0
29
-100
]})]
(
is
(
=
{
:version
"4.0.28-23"
:semantic-version
[
4
0
29
]}
(
driver/dbms-version
:mongo
(
mt/db
))))))
(
testing
"Any values after rubbish in versionArray are ignored"
(
with-redefs
[
mg/command
(
constantly
{
"version"
"4.0.28-23"
"versionArray"
[
4
0
"NaN"
29
]})]
(
is
(
=
{
:version
"4.0.28-23"
:semantic-version
[
4
0
]}
(
driver/dbms-version
:mongo
(
mt/db
))))))))
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