Skip to content

Commit

Permalink
don't hardcode id, use primary key
Browse files Browse the repository at this point in the history
  • Loading branch information
leafo committed Apr 9, 2016
1 parent be83984 commit 75e90f2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lapis/db/base_model.lua
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ do
if not flip and type(self.primary_key) == "table" then
error(tostring(self:table_name()) .. " must have singular primary key for include_in")
end
local src_key = flip and (opts.local_key or "id") or foreign_key
local src_key = flip and (opts.local_key or self:primary_keys()) or foreign_key
local include_ids
do
local _accum_0 = { }
Expand Down
2 changes: 1 addition & 1 deletion lapis/db/base_model.moon
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class BaseModel
if not flip and type(@primary_key) == "table"
error "#{@table_name!} must have singular primary key for include_in"

src_key = flip and (opts.local_key or "id") or foreign_key
src_key = flip and (opts.local_key or @primary_keys!) or foreign_key
include_ids = for record in *other_records
with id = record[src_key]
continue unless id
Expand Down

0 comments on commit 75e90f2

Please sign in to comment.