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
131ebfe2
Commit
131ebfe2
authored
9 years ago
by
Cam Saul
Browse files
Options
Downloads
Patches
Plain Diff
optimize read-check macro to no-op for a Database since @(:can-read db) is always true
parent
2827a7b1
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/metabase/api/common.clj
+11
-1
11 additions, 1 deletion
src/metabase/api/common.clj
with
11 additions
and
1 deletion
src/metabase/api/common.clj
+
11
−
1
View file @
131ebfe2
...
...
@@ -442,7 +442,17 @@
(
check-403
@~
'can_read
)
obj
#
))
([
entity
id
]
`
(
read-check
(
sel
:one
~
entity
:id
~
id
))))
(
cond
;; simple optimization : since @can-read is always true for a Database
;; the read-check macro will just resolve to true in this simple case
;; use `name` so we can match 'Database or 'metabase.models.database/Database
;;
;; TODO - it would be nice to generalize the read-checking pattern, and make it
;; a separate multimethod or protocol so other models besides DB can write optimized
;; implementations. Currently, we always fetch an *entire* object to do read checking,
;; which is wasteful.
(
=
(
name
entity
)
"Database"
)
`
true
:else
`
(
read-check
(
sel
:one
~
entity
:id
~
id
)))))
(
defmacro
write-check
"Checks that `@can_write` is true for this object."
...
...
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