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
25e24b0f
Commit
25e24b0f
authored
8 years ago
by
Allen Gilliland
Browse files
Options
Downloads
Plain Diff
Merge pull request #2242 from metabase/fix-nullpointer
Fix nullpointer
parents
8493ce7b
f350ea1b
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/metabase/driver/mongo.clj
+14
-10
14 additions, 10 deletions
src/metabase/driver/mongo.clj
src/metabase/util.clj
+3
-2
3 additions, 2 deletions
src/metabase/util.clj
test/metabase/util_test.clj
+1
-1
1 addition, 1 deletion
test/metabase/util_test.clj
with
18 additions
and
13 deletions
src/metabase/driver/mongo.clj
+
14
−
10
View file @
25e24b0f
(
ns
metabase.driver.mongo
"MongoDB Driver."
(
:require
[
clojure.set
:as
set
]
[
clojure.tools.logging
:as
log
]
(
monger
[
collection
:as
mc
]
[
command
:as
cmd
]
[
conversion
:as
conv
]
...
...
@@ -118,16 +119,19 @@
(
defn-
describe-table
[
table
]
(
with-mongo-connection
[
^
com.mongodb.DB
conn
(
table/database
table
)]
;; TODO: ideally this would take the LAST set of rows added to the table so we could ensure this data changes on reruns
(
let
[
parsed-rows
(
->>
(
mc/find-maps
conn
(
:name
table
))
(
take
driver/max-sync-lazy-seq-results
)
(
reduce
(
fn
[
field-defs
row
]
(
loop
[[
k
&
more-keys
]
(
keys
row
)
fields
field-defs
]
(
if-not
k
fields
(
recur
more-keys
(
update
fields
k
(
partial
update-field-attrs
(
k
row
)))))))
{}))]
(
let
[
parsed-rows
(
try
(
->>
(
mc/find-maps
conn
(
:name
table
))
(
take
driver/max-sync-lazy-seq-results
)
(
reduce
(
fn
[
field-defs
row
]
(
loop
[[
k
&
more-keys
]
(
keys
row
)
fields
field-defs
]
(
if-not
k
fields
(
recur
more-keys
(
update
fields
k
(
partial
update-field-attrs
(
k
row
)))))))
{}))
(
catch
Throwable
t
(
log/error
(
format
"Error introspecting collection: %s"
(
:name
table
))
t
)))]
{
:name
(
:name
table
)
:fields
(
set
(
for
[
field
(
keys
parsed-rows
)]
(
describe-table-field
field
(
field
parsed-rows
))))})))
...
...
This diff is collapsed.
Click to expand it.
src/metabase/util.clj
+
3
−
2
View file @
25e24b0f
...
...
@@ -365,8 +365,9 @@
(
when-let
[
^
java.net.URL
url
(
try
(
java.net.URL.
string
)
(
catch
java.net.MalformedURLException
_
nil
))]
(
and
(
re-matches
#
"^https?$"
(
.getProtocol
url
))
; these are both automatically downcased
(
re-matches
#
"^.+\..{2,}$"
(
.getAuthority
url
)))))))
; this is the part like 'google.com'. Make sure it contains at least one period and 2+ letter TLD
(
when
(
and
(
.getProtocol
url
)
(
.getAuthority
url
))
(
and
(
re-matches
#
"^https?$"
(
.getProtocol
url
))
; these are both automatically downcased
(
re-matches
#
"^.+\..{2,}$"
(
.getAuthority
url
))))))))
; this is the part like 'google.com'. Make sure it contains at least one period and 2+ letter TLD
(
def
^
:private
^
:const
host-up-timeout
"Timeout (in ms) for checking if a host is available with `host-up?` and `host-port-up?`."
...
...
This diff is collapsed.
Click to expand it.
test/metabase/util_test.clj
+
1
−
1
View file @
25e24b0f
...
...
@@ -113,7 +113,7 @@
(
expect
false
(
is-url?
"http://metabasecom"
))
; no period / TLD
(
expect
false
(
is-url?
"http://.com"
))
; no domain
(
expect
false
(
is-url?
"http://google."
))
; no TLD
(
expect
false
(
is-url?
"http:/"
))
; nil .getAuthority needs to be handled or NullPointerException
;;; ## tests for RPARTIAL
...
...
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