Open codetheweb opened 2 years ago
Thanks @codetheweb. Have reproduced.
Two options come to mind: we could make things more complex by introducing an UnprefixedTables
type, and using that for the of
option of lock
; or we could simplify things by typing the of
option simply as string
.
I think I might lean towards the latter option, if only because it's also possible to specify a table alias for of
, which is ruled out by the more complex solution (although I guess you'd still have that option to manually cast to UnprefixedTable
). For example:
db.select("UK.constituencies", db.all, { alias: "uc", lock: { for: "UPDATE", of: "uc" } })
What do you think?
Good point, I think typing it as string
makes sense.
Great. In fact I had a rethink, realising it's quite simple to take off the schema with a template string type. This is on master
now, plus it also lets you use the alias from the alias
option.
I'm away this week, but I'll release a new version when I'm back.
Currently, the
of
parameter of thelock
option accepts aTable
string. This doesn't type check properly when using a schema outside the default search path, as the Zapatos type expectsmyschema.mytable
to be provided toof
but the correct syntax ismytable
(will throw withFOR NO KEY UPDATE must specify unqualified relation names
ifmyschema.mytable
is provided).In other words, this generates the correct query but throws a type error:
This isn't urgent as we can just manually cast
mytable as Table
for now. :)