Skip to content

Commit

Permalink
Update crud.qtpl
Browse files Browse the repository at this point in the history
problem that if next field is empty, it resets prev field to nil

if m.Password == nil {
        ps.stmt.BindNull(3)
    } else {
        ps.stmt.BindText(4, *m.Password)
    }
    if m.CreatedAt == nil {
        ps.stmt.BindNull(4)
    } else {
        ps.stmt.BindFloat(5, toolbelt.TimeToJulianDay(*m.CreatedAt))
    }
  • Loading branch information
blinkinglight authored Oct 6, 2024
1 parent 358b3ae commit 0849cc0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sqlc-gen-zombiezen/zombiezen/crud.qtpl
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,10 @@ func OnceDelete{%s t.SingleName.Pascal %}(tx *sqlite.Conn, id int64) error {
{% endfunc %}

{%- func bindFields( tbl *GenerateCRUDTable) -%}
{%- for col, f := range tbl.Fields -%}
{%- for _, f := range tbl.Fields -%}
{%- if f.IsNullable -%}
if m.{%s f.Name.Pascal %} == nil {
ps.stmt.BindNull({%d col %})
ps.stmt.BindNull({%d f.Column %})
} else {
{%= bindField(f, true) -%}
}
Expand Down Expand Up @@ -273,4 +273,4 @@ func OnceDelete{%s t.SingleName.Pascal %}(tx *sqlite.Conn, id int64) error {
{%- default -%}
ps.stmt.Column{%s f.SQLType.Pascal %}({%d i %})
{%- endswitch -%}
{%- endfunc -%}
{%- endfunc -%}

0 comments on commit 0849cc0

Please sign in to comment.