Comments (1)
tl;dr: Try using .Value()
method to control which value gets appended to the query.
The following should work:
db.NewUpdate().
Model(entity).
Column("is_active").
Value("is_active", "false"). // will substitute to is_active = false
WherePK().
Exec(ctx)
This is a workaround, because the behaviour you've described looks buggy. For more about that, read on.
This happens because any field that has a bun:"default:x"
tag also gets a "nullzero"
tag.:
Lines 378 to 381 in 8a43835
Why? Because for INSERT
queries bun
needs to be able to correctly decide to append DEFAULT
placeholder for a field that has a zero value:
Lines 335 to 338 in 8a43835
That's helpful, even though not all dialects support this feature (looking at you, SQLite).
But then, once we try to set a field that has a default value to false
(zero boolean value) in UpdateQuery
we get the bug you've described. It happens here:
Lines 97 to 99 in 8a43835
I think adding a checking for HasDefault bool
field to schema.Field
and using itSQLDefault != ""
in the InsertQuery
instead would be a good long-term solution.
from bun.
Related Issues (20)
- how do i exec multiple queries as a single query? HOT 2
- regression: models with nested embedded structs not handled properly HOT 1
- ParseInt Error
- Problem with reconnection to postgres
- pgx driver example is wrong and not working
- Go migrations are not discovered
- Custom sum column on a relation
- In v1.2, about 'unique' tag option in embedded structures HOT 1
- Call BeforeAppendModel on embedded types
- incorrect CTE generation
- Is []int64 supported for Arrays
- Support for DuckDB dialect
- Ambiguous Column Reference Id
- Scan error on column: bun: Scan(unsupported [32]uint8)"
- m2m relations with composite keys
- can't scan 1 (float32) into float32 HOT 2
- Issue: Panic on Bulk Upsert with Pointer Fields in Slice of Interfaces HOT 1
- Documentation Pgx section update HOT 2
- Is it possible to insert a comment before or after a sql query?
- how can i tag index in struct filed?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bun.