-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(db): allow primary key passed as full entity to DAOs #11695
Conversation
A follow up for this PR would be to allow foreign keys to be given as full entities, like this: Before: local service = kong.db.services:insert({ url = "http://test.test/" })
local route = kong.db.routes:insert({
paths = { "/test" },
service = { id = service.id },
}) After: local service = kong.db.services:insert({ url = "http://test.test/" })
local route = kong.db.routes:insert({
paths = { "/test" },
service = service,
}) |
22899bd
to
455222b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome 🚀
455222b
to
74e421e
Compare
74e421e
to
3db5788
Compare
3e6c8ed
to
6364a60
Compare
### Summary Previously you needed to write code like this: ```lua local route = kong.db.routes:select_by_name("my-route") kong.db.routes:update({ id = route.id }, { paths = { "/test" } }) kong.db.routes:delete({ id = route.id }) ``` with this change you can write it like this: ```lua local route = kong.db.routes:select_by_name("my-route") kong.db.routes:update(route, { paths = { "/test" } }) kong.db.routes:delete(route) ``` You can pass full entity to all the places that previously required the just the primary key. Signed-off-by: Aapo Talvensaari <[email protected]>
6364a60
to
7c477bc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me
Cherry-pick failed for Please cherry-pick the changes locally. git remote add upstream https://github.com/kong/kong-ee
git fetch upstream master
git worktree add -d .worktree/cherry-pick-11695-to-master-to-upstream upstream/master
cd .worktree/cherry-pick-11695-to-master-to-upstream
git checkout -b cherry-pick-11695-to-master-to-upstream
ancref=$(git merge-base 4b12b2394440ad8474fb16bde5081116da5983a3 7c477bcb2bfcba03ba674d9aa49823c487f4eaf0)
git cherry-pick -x $ancref..7c477bcb2bfcba03ba674d9aa49823c487f4eaf0 |
Summary
Previously you needed to write code like this:
with this change you can write it like this:
Checklist
CHANGELOG/unreleased/kong
or addingskip-changelog
label on PR if unnecessary. README.md