You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
type Product struct {
Id int
PropertyGroup PropertyGroup `ref:"property_group_id" fk:"id" autosave:"true" autoload:"true"`
PropertyGroupId int
}
type PropertyGroup struct {
Id int
Properties []Property `ref:"id" fk:"group_id" autosave:"true" autoload:"true"`
}
type Property struct {
Id int
Key string
Value string
Group PropertyGroup `ref:"group_id" fk:"id"`
GroupId int
}
Please note that what's important here is the PropertyGroup, which has no data fields. I kept Property in sample only to show what I want to achieve and why I might need such an empty table.
When doing the insert for Product, with a reference to an existing PropertyGroup, I have this error: pq: syntax error at or near "WHERE"
Generated sql is this: UPDATE "property_groups" SET WHERE "property_groups"."id"=$1; - pq: syntax error at or near "WHERE"
Of course an workaround might be to remove the autosave:"true" between Product and PropertyGroup, but this would break the insert when the PropertyGroup doesn't exist.
The text was updated successfully, but these errors were encountered:
Of course an workaround might be to remove the autosave:"true" between Product and PropertyGroup, but this would break the insert when the PropertyGroup doesn't exist.
one possible fix that I can think of is to not do any updates/insert if the struct only have primary fields, but this will still break the insert if property group doesn't exists 🤔
with a reference to an existing PropertyGroup
seems the best way to go here is to disable autosave and set property group using PropertyGroupId
I have a mapping like this:
Please note that what's important here is the PropertyGroup, which has no data fields. I kept Property in sample only to show what I want to achieve and why I might need such an empty table.
When doing the insert for Product, with a reference to an existing PropertyGroup, I have this error:
pq: syntax error at or near "WHERE"
Generated sql is this:
UPDATE "property_groups" SET WHERE "property_groups"."id"=$1; - pq: syntax error at or near "WHERE"
Of course an workaround might be to remove the autosave:"true" between Product and PropertyGroup, but this would break the insert when the PropertyGroup doesn't exist.
The text was updated successfully, but these errors were encountered: