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
func (q*CreateTableQuery) beforeCreateTableHook(ctx context.Context) error {
ifhook, ok:=q.table.ZeroIface.(BeforeCreateTableHook); ok { // panic on this line because ZeroIface is niliferr:=hook.BeforeCreateTable(ctx, q); err!=nil {
returnerr
}
}
returnnil
}
It panic because, I think, I am not specifying a "model", by calling the Model() function. However, when I do this, giving a "dummy" struct with zero field as the model, I instead get the following query:
CREATE TEMP TABLE IF NOT EXISTS my_temp_table_name AS (selectQuery) ()
Notice the empty () at the end of the query. It causes a syntax error on SQL.
Any idea on how I could solve this ? (besides executing a raw query if possible)
The text was updated successfully, but these errors were encountered:
Using bun 1.1.16 here.
I am trying to use
(bun.IDB).NewCreateTable().Temp().IfNotExists().ModelTableExpr("my_temp_table_name AS (?)", selectQuery).Exec(ctx)
(whatever is selectQuery, it is just a query using SELECT ...)
I would expect this call to render this query:
CREATE TEMP TABLE IF NOT EXISTS my_temp_table_name AS (selectQuery)
which at least on Postgres is supported: https://www.postgresql.org/docs/current/sql-createtable.htmlInstead of rendering the query, the code panics: invalid memory address or nil pointer dereference
It panic because, I think, I am not specifying a "model", by calling the
Model()
function. However, when I do this, giving a "dummy" struct with zero field as the model, I instead get the following query:CREATE TEMP TABLE IF NOT EXISTS my_temp_table_name AS (selectQuery) ()
Notice the empty
()
at the end of the query. It causes a syntax error on SQL.Any idea on how I could solve this ? (besides executing a raw query if possible)
The text was updated successfully, but these errors were encountered: