54 Commits
Author SHA1 Message Date
zeekayandHanzo Dev d54045b5f0 Go 1.27.1, and the code it can say more simply
The module declares go 1.27.1. go fix applied the modernizers; omitzero
is not applied, since it changes what the JSON says.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-16 19:56:19 -07:00
zeekay de2de20080 the tests open one driver, and it answers to both names
Four test files named a SQLite engine directly, and two named two of them —
mattn beside modernc in one binary. They register different names so nothing
panicked, but a suite linking two implementations is not exercising the one a
consumer gets.

hanzoai/sqlite is the one import, and mattn leaves the module entirely. Since
v0.5.6 the driver registers "sqlite" AND aliases "sqlite3" to the same value on
both builds, so core/db_test.go keeps opening "sqlite3" — and now does so on the
cgo-free build, where that name did not resolve at all.

Also passes the error the log line already asked for: the table-inference failure
declared %s and %v and supplied one argument, so the reason a table could not be
inferred rendered as MISSING. go vet is clean.
2026-08-21 08:21:59 -07:00
zeekay 7d0ad4da5d fork: xorm.io/xorm → github.com/hanzoai/xorm 2026-04-06 20:45:59 -07:00
Lunny Xiao d42fd0fd44 Fix bug when invoking session in the after load (#2569)
Fix #2511

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2569
2026-02-09 01:39:56 +00:00
Lunny Xiao 3699b62f47 Fix noautocond conflict with unscoped (#2559)
Replace #2418

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2559
2026-02-08 19:37:14 +00:00
Lunny Xiao a24c7ec8e4 Fix queryinterface (#2562)
Fix #2543

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2562
2026-02-08 18:08:13 +00:00
Lunny Xiao e4b1d12839 Fix auto time fields during transactional inserts/updates (#2567)
This PR fixes #2521 where `created`/`updated` (and version) fields were not populated on beans when inserting/updating inside a transaction. The fix applies auto-time/version setters immediately after insert/update, rather than deferring them to `afterClosures`, and adds a transaction test to ensure the fields are set before commit/rollback. Minor formatting cleanup included.

Since `session.afterClosures` will only be invoked after the transaction succeed. so that the time will not be set when insert invoking inside a transaction.

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2567
2026-02-08 18:00:49 +00:00
Lunny Xiao 50af48a8e6 Fix bug after was not cleaned if execution failed (#2560)
Fix #2546

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2560
2026-02-08 17:53:41 +00:00
Lunny Xiao f05bba8672 Fix bug when invoking buildAfterProcessors (#2563)
Fix #2547

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2563
2026-02-08 07:33:58 +00:00
Lunny Xiao 2782d3765a Fix created time could not be updated (#2564)
Fix #2523

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2564
2026-02-08 07:07:28 +00:00
Lunny Xiao ec77bd214b Support select for update of postgres (#2557)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2557
2026-02-08 03:07:57 +00:00
王忠强andLunny Xiao fe8a5b2cc0 Add a new GetOrError method that returns an error when the record does not exist. (#2366)
Resolve https://gitea.com/xorm/xorm/issues/2328#issue-220740

---------

Co-authored-by: Lunny Xiao <[email protected]>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2366
Reviewed-by: Lunny Xiao <[email protected]>
Co-authored-by: 王忠强 <[email protected]>
Co-committed-by: 王忠强 <[email protected]>
2026-02-08 01:20:20 +00:00
Lunny Xiao 7c6cbc4cfd Fix distinct count bug (#2555)
Replace #2402

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2555
2026-02-08 01:17:16 +00:00
Lunny Xiao 6f49f3755b Fix get bug missed deleted (#2553)
Fix #2456
Replace #2457

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2553
2026-02-08 01:04:13 +00:00
Lunny Xiao 172d9452a6 Optimize find and count (#2552)
replace #2467

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2552
2026-02-08 00:14:29 +00:00
Lunny Xiao 1a3c9ee2db use golang ci lint v1 (#2551)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2551
2026-02-07 23:53:33 +00:00
Lunny Xiao 8c2132d511 Add lint and fix code (#2549)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2549
2026-02-07 18:40:04 +00:00
Jinhan HeandLunny Xiao 469c06e1e3 fix(asDBCond): check string when driver.Valuer return string instead of pointer (#2541)
Description:
  the bug is due to `driver.Valuer()` return a non-pointer type value, no check this value and return true directly.  [decimal](https://github.com/shopspring/decimal) is a widely used type in most business scenarios, so I think it's necessary to compatible with the [decimal](https://github.com/shopspring/decimal)

What's changes:
 - check string value
 - be compatible  with [decimal](https://github.com/shopspring/decimal)

close #2411

Test Result:
`
=== RUN   TestColumnsStringGeneration
--- PASS: TestColumnsStringGeneration (0.00s)
=== RUN   TestConvertSQLOrArgs
--- PASS: TestConvertSQLOrArgs (0.00s)
=== RUN   TestAsDbCondWhenFieldValueIsDriverValuer
--- PASS: TestAsDbCondWhenFieldValueIsDriverValuer (0.00s)
PASS
`

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2541
Reviewed-by: Lunny Xiao <[email protected]>
Co-authored-by: Jinhan He <[email protected]>
Co-committed-by: Jinhan He <[email protected]>
2025-10-19 18:30:08 +00:00
Lunny Xiao 34a11c5daa Upgrade pgx (#2534)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2534
2025-09-15 02:41:04 +00:00
Lunny Xiao ece5dace20 upgrade go to 1.20 (#2531)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2531
2025-09-14 05:34:55 +00:00
Lunny Xiao 418033da51 Fix bug when json with a real SQLType in the tag (#2519)
Fix a bug when the tag have both `longtext json`. It should be `longtext` column type with JSON support.

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2519
2025-07-21 18:19:39 +00:00
Lunny Xiao cd1aff65cf Add more tests for extends (#2443)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2443
2024-05-09 12:47:01 +00:00
lijunshiandLunny Xiao 04e79701c9 fix: Sync2 will remove AUTO_INCREMENT unexpectly (#2444) (#2445)
fix #2444

Co-authored-by: Lunny Xiao <[email protected]>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2445
Reviewed-by: Lunny Xiao <[email protected]>
Co-authored-by: lijunshi <[email protected]>
Co-committed-by: lijunshi <[email protected]>
2024-04-28 16:12:17 +00:00
265d843c05 Add includeNil requiredField Check when custom struct field IsZero in Update method. (#2438)
Add includeNil requiredField Check when custom struct field IsZero in Update method.

Co-authored-by: tyler <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2438
Reviewed-by: Lunny Xiao <[email protected]>
Co-authored-by: tylerthail2019 <[email protected]>
Co-committed-by: tylerthail2019 <[email protected]>
2024-04-02 04:26:41 +00:00
d3710f39cc add IsZero check for custom struct column in the Update method (#2417)
Co-authored-by: tyler <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2417
Reviewed-by: Lunny Xiao <[email protected]>
Co-authored-by: tylerthail2019 <[email protected]>
Co-committed-by: tylerthail2019 <[email protected]>
2024-03-18 06:43:33 +00:00
Lunny Xiao 70a63b6ed2 Support not drop index when sync (#2429)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2429
2024-03-15 03:13:09 +00:00
a4ae3d3615 Fix the issue of incorrect insertion of data in non UTC time zone zero for numeric types (#2413)
Fix the issue of incorrect insertion of data in non-UTC time zone zero for numeric types

Co-authored-by: CyJay <[email protected]>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2413
Reviewed-by: Lunny Xiao <[email protected]>
Co-authored-by: CyJaySong <[email protected]>
Co-committed-by: CyJaySong <[email protected]>
2024-02-25 16:16:56 +00:00
Lunny Xiao 67cd694aaf Use github.com/microsoft/go-mssqldb instead of old mssqldb repository (#2386) (#2390)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2386
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2390
2024-01-16 07:56:04 +00:00
Lunny Xiao 07965913ee Fix #2393 (#2395)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2395
2024-01-15 14:06:34 +00:00
Lunny Xiao 556ce2553d Fix mssql get indexes bug when collation is not default with collation test for mssql (#2387) (#2389)
backport #2387

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2387

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2389
2023-12-31 14:39:33 +00:00
Lunny Xiao 922106daf1 Implement update join (#2383) (#2385)
backport #2383

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2383

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2385
2023-12-30 10:50:02 +00:00
Lunny Xiao 3e973bc948 Fix use hint with join bug (#2384)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2384
2023-12-30 06:28:44 +00:00
Lunny Xiao 32d5823163 Add missing index hint parameter (#2378)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2378
2023-12-19 04:54:04 +00:00
Lunny Xiao d3e1cdd8a0 Add index hint support (#2375)
Fix #1456

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2375
2023-12-15 02:17:13 +00:00
Lunny Xiao d23eb44091 Fix bug when join with alias start with a (#2343)
Fix #2331

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2343
2023-10-25 11:01:46 +00:00
Lunny Xiao 66bce37646 some refactors for write functions (#2342)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2342
2023-10-25 07:11:18 +00:00
lng2020andLunny Xiao e6ef7675a6 Revert "Fix deleted tag attribute zeroTime is not DatabaseTZ (#2299)" (#2341)
Related #2339

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2341
Co-authored-by: lng2020 <[email protected]>
Co-committed-by: lng2020 <[email protected]>
2023-10-17 09:41:42 +00:00
FlyingOnionandLunny Xiao b8e66c03b7 modify limit offset implement (#2188)
Oracle and SQLServer specific: When `LIMIT OFFSET` function is needed, use `OFFSET <offset> ROWS FETCH NEXT <limit> ROWS ONLY` to replace legacy subquery.

SQLServer specific: When `ORDER BY` is not set and `OFFSET FETCH` is set, set `statement.orderStr` to `1` (`ORDER BY 1`). See [here](https://learn.microsoft.com/zh-cn/sql/t-sql/queries/select-order-by-clause-transact-sql?view=sql-server-ver16).

MySQL specific: When limit is 0 and offset > 0, use `LIMIT 9223372036854775807` ($2^{63}-1$). See comments [here](https://gitea.com/xorm/xorm/src/commit/15d171ea55a011eec76910353d5d8d17397d78e4/internal/statements/query.go#L314).

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2188
Reviewed-by: Lunny Xiao <[email protected]>
Co-authored-by: FlyingOnion <[email protected]>
Co-committed-by: FlyingOnion <[email protected]>
2023-09-20 02:07:03 +00:00
Ryan LiuandLunny Xiao 60d41e5766 fix the error in mysql: unknown colType UNSIGNED FLOAT (#2143)
Error: unknown colType UNSIGNED FLOAT
in mysql 5.6.27 or 5.7.32

Fix #2123

Co-authored-by: Lunny Xiao <[email protected]>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2143
Co-authored-by: Ryan Liu <[email protected]>
Co-committed-by: Ryan Liu <[email protected]>
2023-09-16 15:43:12 +00:00
6543andLunny Xiao c122cfd093 Remove dead code from session.SyncWithOptions() (#2323)
https://gitea.com/xorm/xorm/src/commit/b61c9ac22e0fb7e560acefa6c8cd68687c4d8cb2/sync.go#L229-L231

as oriIndex only is **not** nil if index.Equal(index2)

and index.Equal(index2) check if `oriIndex.Type == index.Type` ... so it always is false

Co-authored-by: Lunny Xiao <[email protected]>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2323
Reviewed-by: Lunny Xiao <[email protected]>
Co-authored-by: 6543 <[email protected]>
Co-committed-by: 6543 <[email protected]>
2023-09-16 14:41:02 +00:00
Lunny Xiao 4376be638c Add test for max ( id ) (#2316)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2316
2023-09-16 13:48:49 +00:00
6543andLunny Xiao b61c9ac22e Add Sync options to ignore constrains and indices (#2320)
needed for https://github.com/woodpecker-ci/woodpecker/pull/2117

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2320
Reviewed-by: Lunny Xiao <[email protected]>
Co-authored-by: 6543 <[email protected]>
Co-committed-by: 6543 <[email protected]>
2023-08-09 03:28:52 +00:00
Lunny Xiao bf26e9a367 Exec support conversion data (#1970)
Fix #1803

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1970
2023-08-07 10:54:57 +00:00
399a017efe Fix deleted tag attribute zeroTime is not DatabaseTZ (#2299)
Co-authored-by: CyJay <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2299
Reviewed-by: Lunny Xiao <[email protected]>
Co-authored-by: CyJaySong <[email protected]>
Co-committed-by: CyJaySong <[email protected]>
2023-08-07 04:28:55 +00:00
Lunny Xiao 1c1fd917e1 remove unused files 2023-07-26 18:45:28 +08:00
Lunny Xiao 633372c20f Move integrations -> tests (#2314)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2314
2023-07-26 10:44:41 +00:00
Lunny Xiao f30dadfd02 move tests to a sereprated repository 2014-04-11 17:22:21 +08:00
Lunny Xiao 128db9c792 bug fixed and tests passed 2014-04-11 17:04:39 +08:00
Lunny Xiao 5080b2b571 Merge branch 'master' into dev
Conflicts:
	dialects/oracle.go
	dialects/postgres.go
	docs/QuickStart.md
	engine.go
	mysql.go
	session.go
	statement.go
	table.go
	tests/base_test.go
	xorm.go
	xorm/go.go
	xorm/reverse.go
2014-04-11 15:37:27 +08:00
Lunny Xiao e77fca31ae move tests to tests subdir & refactoring 2014-01-25 10:07:11 +08:00