841 Commits

Author SHA1 Message Date
Billy Chan
71dbffc725
Fix clippy (#1426)
* Fix clippy

* Fix clippy
2023-01-27 18:50:20 +08:00
Chris Tsang
5683c83189 Changelog & Docs 2023-01-26 23:36:16 +08:00
Billy Chan
4e1a0e4a7c
Allows offset & limit to take Option<u64> (#1410)
* Allows offset & limit to take `Option<u64>`

* Takes `Into<Option<u64>>` instead

* Reset limit and offset when None value is provided
2023-01-27 13:03:13 +08:00
Chris Tsang
37704e1ed8
Merge pull request #1425 from SeaQL/record_not_updated
RecordNotFound -> RecordNotUpdated
2023-01-26 18:41:11 +08:00
Billy Chan
1c43508b66
QueryTrait::maybe: a general purpose query customizer (#1415)
* Added `QueryTrait::maybe`

* Make the API better

* Docs

* Update src/query/traits.rs

Co-authored-by: Chris Tsang <chris.2y3@outlook.com>
2023-01-26 17:48:25 +08:00
Chris Tsang
b3e4d1c1cf RecordNotFound -> RecordNotUpdated 2023-01-25 15:43:44 +08:00
Billy Chan
036edf9d70
Noop when update without providing any values (#1384)
* Noop when update without providing any values

* Add tests

* Update Cargo.toml

* Bump SeaQuery's version

* Fixup

Co-authored-by: Chris Tsang <chris.2y3@outlook.com>
2023-01-26 17:12:50 +08:00
Chris Tsang
03207fbda9 Use rows_affected when DB does not support returning 2023-01-18 21:18:04 +08:00
Chris Tsang
a465d1ebac Refactor 2 2023-01-18 20:46:02 +08:00
Chris Tsang
07d5f781ca Refactor 2023-01-18 20:08:10 +08:00
Chris Tsang
e5b69ebb73 Don't call last_insert_id if not needed 2023-01-18 19:06:06 +08:00
LeoniePhiline
f03424e7f7
fix(docs): Fix a small typo (#1391) 2023-01-18 18:45:35 +08:00
Billy Chan
e2b796b093
Cont. feat: expose database connection to ActiveModelBehaviour's methods (#1328)
* feat: expose database connection to `ActiveModelBehaviour`'s methods (#1145)

* Make ActiveModelTrait async

* Add tests

* refactoring

Co-authored-by: teenjuna <53595243+teenjuna@users.noreply.github.com>
2023-01-12 17:22:46 +08:00
Billy Chan
cb71e265df
Unchanged ActiveValue as Set (#1177)
* Unchanged ActiveValue as Set

* Renaming

* Rename

* Rename methods
2023-01-12 15:42:13 +08:00
Chris Tsang
395203bd06 Docs 2023-01-12 14:09:26 +08:00
Billy Chan
e9df3aa01d
Casting columns as a different data type on select, insert and update (#1304)
* Cast select and value

* Refactoring

* Test casting Postgres citext

* Fixup

* Revert

* Add test cases

* Fixup

* Rename methods
2023-01-12 14:56:11 +08:00
Chris Tsang
bb5dead0c8 Docs 2023-01-12 13:55:39 +08:00
Chris Tsang
0787035a42 Docs 2023-01-12 13:51:43 +08:00
Billy Chan
a0d972633a
Implement LoaderTrait for slices (#1368) 2023-01-11 19:12:45 +08:00
Billy Chan
0756adf647
find_by_id and delete_by_id take any Into primary key value (#1362) 2023-01-11 15:28:10 +08:00
Billy Chan
c49a8ac843
Fix merge conflict (#1386)
* Fix merge conflict

* remove unnecessary clone
2023-01-11 15:27:34 +08:00
Billy Chan
cbd7a8d1c9
Cleanup the use of vec![] (#1367)
* Public methods accept any IntoIterator as argument

* refactoring
2023-01-11 14:17:06 +08:00
Billy Chan
b5e984ca4a
Postgres insert many will throw RecordNotInserted error if non of them are being inserted (#1021) 2023-01-11 14:16:35 +08:00
Billy Chan
4f5a15a99f
Support various UUID formats that are available in uuid::fmt module (#1325)
* Support various UUID formats that are available in `uuid::fmt` module

* clippy

* fixup
2023-01-11 14:13:15 +08:00
Chris Tsang
2cb9824a18 Mascot 2023-01-10 16:45:38 +08:00
Panagiotis Karatakis
c83c674612
Add is_null getter for ColumnDef struct (#1381)
* Add is_null getter for ColumnDef struct

* Update src/entity/column.rs

* Update src/entity/column.rs

Co-authored-by: Chris Tsang <chris.2y3@outlook.com>
2023-01-10 16:36:02 +08:00
Chris Tsang
ed7be8a29b Improve error message 2023-01-10 15:35:56 +08:00
Chris Tsang
23ee592dae Changelog 2023-01-10 15:29:02 +08:00
Chris Tsang
4210526ec1
Merge pull request #1311 from SeaQL/select-into-tuple
Select into tuple
2023-01-10 15:20:14 +08:00
Chris Tsang
3ae44a0abd One more tweak 2023-01-09 15:46:41 +08:00
Chris Tsang
d14e4a2160 Fix again 2023-01-09 15:20:01 +08:00
Chris Tsang
5c93253877 Tests 2023-01-09 14:46:19 +08:00
Chris Tsang
f0634c2451 Well clippy 2023-01-09 14:26:11 +08:00
Chris Tsang
566dac0661 Docs 2023-01-09 14:11:57 +08:00
Chris Tsang
a11c57d337 Introduce ColIdx 2023-01-09 14:02:23 +08:00
Billy Chan
e246d3faaf
Cont. Upgrade to SeaQuery 0.28.0 (#1366)
* Upgrade to SeaQuery 0.28.0

* Remove unnecessary heap allocation

* Upgrade sea-query-binder

* Upgrade sea-schema

* Fix

* Upgrade sea-schema

* refactoring

Co-authored-by: Ivan Krivosheev <py.krivosheev@gmail.com>
2023-01-05 20:41:28 +08:00
Billy Chan
e927a0e5f5
Execute unprepared statement (#1327) 2023-01-05 14:08:18 +08:00
Billy Chan
d332afa99c
Get SQLx connection pool (#1297) 2023-01-05 14:08:10 +08:00
Chris Tsang
d80e61ed7e
Add files via upload 2023-01-02 18:26:20 +08:00
Chris Tsang
7e630157a0
Docs 2023-01-01 19:23:38 +08:00
Chris Tsang
eeec2cf06f
Merge pull request #1238 from karatakis/dataloader
[PIP] Simple data loader
2022-12-28 15:59:04 +08:00
Chris Tsang
7f96418fa3
Small tweak 2022-12-28 15:57:40 +08:00
Billy Chan
5291c7f551
clippy 2022-12-20 15:56:37 +08:00
Billy Chan
2f00a8757d
Merge branch 'master' into select-into-tuple 2022-12-20 15:51:06 +08:00
Billy Chan
3cd834d40c
docs 2022-12-20 15:43:03 +08:00
mohs8421
1f27837f49
refactoring Schema to expose functions for database updates (#1256)
* extracting get_column_def from create_table_from_entity to make it available for database upgrade processes.

* Align code example formatting

* Converting the foreign key related code from create_table_from_entity into From<RelationDef> implementations to make its usage easier in different context, like updating a database.

* Refactor

* Fixup

Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>
2022-12-19 17:24:11 +08:00
Billy Chan
17ed7156c4
Fix: update many cast enum values (#1178) 2022-12-19 17:09:18 +08:00
Billy Chan
7757a46c46
clippy 2022-12-16 21:36:00 +08:00
Antonio Scandurra
df2dcdabac
Prevent returning connections to pool with a positive transaction depth (#1283)
Mark transaction as closed *only* after commit/rollback succeeds.

Previously, `open` on the transaction would be set to `false` prior to attempting
to commit or rollback the transaction. When the operation failed, for example, due
to a serialization failure with a serializable isolation level, this would leave
the transaction in an inconsistent state, where it thought it was closed but really
it was still open. The connection would then be returned to the connection pool with
a transaction depth of 1, causing a savepoint to be erroneously created the next time
a transaction was created for the connection.

By waiting to set `open` to `false` until the commit/rollback succeeds, a failure
to do either will result in us correctly rolling back the transaction when dropping
it, ensuring that the connection is returned to the pool with a transaction depth
of 0. Note that this is consistent with how `sqlx` handles transactions.

We attempted to write a test, but had a very difficult time forcing postgres to fail
to commit a transaction. We found that it would block our requests instead when creating
conflicting updates, and we couldn't find any information about when it blocks vs when
transaction commits fail.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>

Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-12-16 21:11:51 +08:00
Billy Chan
ccca35ab1a
clippy 2022-12-16 16:48:16 +08:00