365 Commits

Author SHA1 Message Date
Billy Chan
cef380b977
SQLite type mappings (#2077)
* sqlite: deps

* sqlite: update data type mappings

* sqlite: decimal test cases

* sqlite: try negative numbers

* fixup

* fixup

* fmt

* clippy

* fixup

* fixup

* fixup

* refactor

* fix

* Drop the use of `rust_decimal_macros` (#2078)

* sqlite: decimal -> real

* revert

* Bump dependencies

* Fixup

* Fixup

* Fixup

* Fixup

* Refactor

* Refactor

* Refactor
2024-02-05 14:42:55 +08:00
Andrea Corradi
c56c072f27
Enable sqlite returning with feature flag (#2070)
* Enable sqlite returning with feature flag

* Add runtime check for sqlite version

* Apply suggestions from code review

* Fix clippy

* Rename feature

* Fix tests when feature flag is not enabled

---------

Co-authored-by: Chris Tsang <chris.2y3@outlook.com>
2024-01-26 04:28:59 +08:00
Billy Chan
9797da1ee4
Drop the use of rust_decimal_macros (#2078) 2024-01-24 17:58:50 +08:00
Maksim Zaborovskiy
c5adb9d1d1
Add cursor pagination desc order (#2037)
* feat: add cursor pagination desc order

* feat: add cursor pagination desc order

* test: add cursor integration tests

* test: add cursor integration tests

* test: add query cursor_by tests

* test: add query cursor_by tests

* test: add query cursor_by tests

* test: add query cursor_by tests

* test: add query cursor_by tests

* test: add query cursor_by sort tests

* chore: remove unused import
2024-01-14 23:23:55 +08:00
Dmitrii Aleksandrov
a73f699578
Cast enums in lt(), lte(), gt(), gte() (#2014)
* Cast enums in lt, lte, gt, gte (revert 10f3de0, discussed under #1527)

* Add tests for enum order comparisons
2024-01-12 22:42:29 +08:00
Chris Tsang
f54683d365
Refactor/fix clippy errors (#2056) (#2057)
* chore: add clippy config file

* refactor: fix clippy errors and wornings of runtime-async-std-native-tls,sqlx-all

* refactor: fix clippy errors and wornings of sqlx-sqlite, sqlx-mysql, sqlx-postgres

* chore: format

* refactor: fix clippy

* fix: import path

* refactor: fix clippy errors and wornings of sqlx-sqlite, sqlx-mysql, sqlx-postgres

* fix: revert some space and comma removal

* fix: revert some space and comma removal

* refactor: add feature flag

* fix: import path

* test: remove mismatch feature flag

* test: remove mismatch feature flag

* chore: add proper feature flag

* chore: remove feature flag

* refactor: remove clippy.toml file

* fix: re-export driver

* fix: re-export JoinType

* fix: remove feature flag

* chore: add #[allow(unused_imports)] for driver

Co-authored-by: Shogo Nakano <61229807+shogo-nakano-desu@users.noreply.github.com>
2024-01-11 00:21:22 +08:00
Chris Tsang
1554db5000 Fixup 2023-12-14 20:21:11 +00:00
Chris Tsang
e10dcd012f Revert "Fixup"
This reverts commit 8a29cba78a45fc6c7fa578dfb0163ec44a77de98.
2023-12-14 20:20:25 +00:00
Chris Tsang
8a29cba78a Fixup 2023-12-14 20:03:02 +00:00
Chris Tsang
b8ad6303d8 Fixup 2023-12-14 19:47:52 +00:00
Dmitrii Aleksandrov
1abc47b5f1
Cast enums in is_in and is_not_in (#1527) (#2002)
* Cast enums in `is_in` and `is_not_in` (#1527)

* Restore original tests, add tests for generated SQL
2023-12-15 03:41:05 +08:00
94eac96513
create_table_from_entity support comment (#2009)
* support table and column comment

* create_table_from_entity support comment

* fmt code

* fmt code

* add comment test

* fix test
2023-12-14 18:22:36 +08:00
Wyatt Herkamp
b4010ecb64
Add #[sea_orm(skip)] for FromQueryResult macro (#1954)
* Add #[sea_orm(skip)] for FromQueryResult macro

* Update sea-orm-rocket

* Revert "Update sea-orm-rocket"

This reverts commit b7226bb44dbdbab9782524feb0303c4c166d3050.
2023-11-08 23:45:38 +08:00
Chris Tsang
77ae46f85f
Merge pull request #1898 from SeaQL/rework-active-enum
Rework ActiveEnum to support TryGetable for Vec<Json>
2023-10-16 10:05:08 +01:00
Chris Tsang
93623f0d02 Support MySQL / SQLite 2023-10-16 09:55:30 +01:00
Chris Tsang
d29ed5b9bb Avoid repeating this 100 times 2023-10-12 13:52:05 +01:00
Anshul Sanghi
201d6fe9f9
Add Tests And Fix Build Issue For "Rework active enum" PR (#1900)
* Add Tests For Root JSON Arrays And Active Enum Vectors

* Fix Build Issue When Using `DeriveActiveEnum`
2023-10-12 16:23:29 +08:00
Ivan Yiu
27ca745208
SelectTwo cursor by, cursorTrait revamp (#1826)
* WIP

* WIP

* test cases for cursor with SelectTwo

* fmt, fix test

* WIP, missing test for also_linked cursor_by

* completed many_to_many relationship

* test fixup

* fmt

* extra order_by to fix test

* WIP

* fixed cursor_by to do ordering implicitly base on both cursor column and primary key from other table

* change from map to for loop to eagerly do order_by

* fix tests
2023-09-23 00:03:04 +08:00
Billy Chan
f6b94c3a7a
Bump chrono to 0.4.30 (#1858)
* Bump `chrono` to 0.4.30

* Fix test cases
2023-09-13 23:03:57 +08:00
Ivan Yiu
d50312c081
Test cases improvement (#1811)
* adds find_with_linked test

* WIP(related test)

* mock related test done

* complete relation test

* loader update

* find_with/also_related missing test case for empty from other side

* comments fixup

* revert loader test

* related select test done

* find with/also linked test cases

* removed due to it being functionally same as the new one

* fmt, remove excess import

* improved model generation

* issue related test case #1790

* added loader test cases and slight improvement to find_related/linked

* miscellaneous changes

* added empty insert, merge load_one test case

* completed loader many to many test case, fmt

* removed empty_insert test case for now

* commented insert_test

* added Cargo.toml for issue 1790's folder

* buffed salvo version for ci(0.49 yanked)

* revert version for salvo example
2023-08-18 20:02:17 +08:00
Anshul Sanghi
5fa2c1c28c
Add Support For PostgreSQL Arrays In FromQueryResult Implementation Of JsonValue (#1598)
* Add Support For PostgreSQL Arrays In FromQueryResult Implementation Of JsonValue

* Add support for root arrays in JSON in SeaORM #1517

* Refactoring

* Only when `postgres-array` is enabled

* Add test cases

---------

Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>
2023-08-02 02:42:16 +08:00
Chris Tsang
ec581abf56 Fix test 2023-07-26 21:09:25 +01:00
Chris Tsang
3f81fd5e89 cargo fmt 2023-07-26 20:27:26 +01:00
Chris Tsang
97ee0a9703 Test derive FromJsonQueryResult 2023-07-26 20:17:55 +01:00
Chris Tsang
8064097639 Comment 2023-07-26 19:03:56 +01:00
Chris Tsang
a5f2ae69e9 Organize entity prelude 2023-07-13 16:53:24 +01:00
darkmmon
fd4aab7a8c
Connection acquire expand (#1737)
* Try connection pool acquire timeout

* expanded ConnectionAcquire Errors, and adjusted relevant functions

* updated to include ClosedConnection
removed unknown as variant of ConnectionAcquireError
updated DbErr Eq

* revert mistakenly edited code

* prolonged the timeout time for connection timeout tests

* Revert "prolonged the timeout time for connection timeout tests"

This reverts commit 04d98cf1fdafe64dbe6168b3bbcdcc813329ac4c.

* Error PartialEq & Eq

* fn conn_acquire_err

* refactor code with conn_acquire_err

* fmt

* error msg

---------

Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>
2023-07-13 23:24:12 +08:00
Chris Tsang
c2d1968627 Reinstate Table => type_name semantic 2023-07-13 11:30:34 +01:00
darkmmon
866025a733
implement DeriveIden in sea-orm only (#1740)
* WIP, implementing Iden

* completed implementation for DeriveIden and added basic test cases

* added feature flag to prevent sea-orm::sea-query::DeriveIden from crashing when sea-query is not used

* fixed doc test and adjusted test case

* enable `sea-query-derive`'s `sea-orm` feature

* Bump `sea-query-derive` to v0.4

* Update Cargo.toml

* Update Cargo.toml

* adjusted test cases and updated so that iden attribute will not be snake cased

* Update Cargo.toml

* Update main.rs

---------

Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>
Co-authored-by: Chris Tsang <chris.2y3@outlook.com>
2023-07-13 16:28:35 +08:00
Chris Tsang
d7a978642e Do not throw RecordNotUpdated error 2023-07-10 20:17:34 +08:00
Billy Chan
53caf94af9 Update many with returning 2023-07-10 20:16:58 +08:00
darkmmon
902c0ed5ff
DeriveDisplay macro for enum (#1726)
* WIP

* WIP

* WIP

* changed from storing ident to storing TokenStream internally

* Push for code sharing

* fmt

* changing test target to string

* updated Display not showing extra single quote, fixed clippy

* removed DeriveDisplay for test case not using display trait

* added test cases for display_value attribute

* Remove useless clone

* Add comment

* Remove useless clone

* Rename method

* Refactoring

---------

Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>
2023-07-10 11:51:19 +08:00
darkmmon
f5a7311794
Derive value type (#1720)
* progress (WIP)

* WIP

* WIP, finished structure except impl programming

* WIP

* revert event_trigger modification

* adding tests and mods

* completed derive value type

* fixed tests, adjusted code position and completed error messages

* column type commit

* added attribute array_type and column_type for specification

* renamed items and files, and removed debug messages

* move attributes outside of the wrapper struct

* refactored code for type matching, and restructured code in test cases

* clippy fix

* fix(doc): fix salvo framework name (#1731)

Co-authored-by: 黄景祥 <jingxiang.huang@baishancloud.com>

* fmt

* changed json_vec_test to use DeriveValueType

* fmt

* Revert "changed json_vec_test to use DeriveValueType"

This reverts commit 92bbf3b6e4eca72e0af0af35776aeec3ee035602.

* added test cases for inserting StringVec in a model

* fmt

* Try non-public wrapped type

* Refactoring

---------

Co-authored-by: joelhy <joelhy@gmail.com>
Co-authored-by: 黄景祥 <jingxiang.huang@baishancloud.com>
Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>
2023-07-10 10:48:20 +08:00
darkmmon
50a7048deb Adding find_with_linked (#1728) 2023-07-07 22:19:45 +08:00
Chris Tsang
1f3fa1dc19 Changelog with Tweaks 2023-06-21 23:14:57 +08:00
darkmmon
6e7950158a
Do nothing on conflict (#1712)
* added Conflicted to TryInsertResult

clippy changes

fmt

change from basic if statement to matches

* changed to early return
2023-06-21 22:47:17 +08:00
Chris Tsang
f7398d1c5c Fixup 2023-06-20 17:59:58 +08:00
Chris Tsang
5e5aa7cbd1 Changelog 2023-06-20 17:23:05 +08:00
darkmmon
92ea837cdf
Make insert statement not panic when inserting nothing (#1708)
* end-of-day commit (WIP)

* progress commit (WIP)

* refactored and added InsertAttempt

* async asjusting

* completed implementation for insertAttempt in execution
Added in tests for insertAttempt

* updated wording for new INSERT type

* removed InsertTrait
2023-06-20 17:17:18 +08:00
darkmmon
b37e7655f8
Added enum for SQLx Error and basic functions for it (#1707)
* Added enum for SQL Error and basic functions for it

* fmt

* Restructured code to allow multiple database system simultaneously

* updated code error and moved Eq to derive by compiler

* added ForeignKeyViolation implementation

* fmt

* added type param

* changed type param and used unwrap_or_default instead of unwrap

* fmt

* refactor code and update documentation

* updated some error code and fixed formatting

* create SQL Err test for UniqueConstraintViolation

* fmt

* updated error codes for mysql errors

* added test for ForeignKeyConstraintViolation and removed unused imports/codes

* fmt

* updated doc and error message

* added static str in SqlErr

* changed to add error message into SqlErr as String

* updated test file to check database type through connection

* fmt

* updated test for SqlErr to match the error type only

* Removed comment and fixed grammar mistake

* fmt

* Update src/error.rs

* Refactoring

---------

Co-authored-by: Chris Tsang <chris.2y3@outlook.com>
Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>
2023-06-19 17:19:08 +08:00
Billy Chan
d35cd6aa3b
Test suit load environment variable from env files (#1701) 2023-06-12 17:19:30 +08:00
Billy Chan
d099669ad8
Cleanup ambiguous glob imports (#1692)
* Cleanup ambiguous glob imports

* fix
2023-06-06 15:00:05 +08:00
Clément Guiton
3ccb9cdbf7
Feat: Expose ping method from SQLx (#1627)
* feat: add connection.ping method

* fmt

* impl `ConnectionTrait::ping` method for `SchemaManagerConnection`

* Mock connection should always be online

* remove needless clippy lint

* fmt

* Remove needless instrument

* Update src/driver/sqlx_sqlite.rs

* <feat>(Ping) removed ping() from ConnectionTrait

* removed ping from transaction

* removed unused imports

* Revert

---------

Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>
Co-authored-by: Chris Tsang <chris.2y3@outlook.com>
2023-06-01 18:21:38 +08:00
Billy Chan
44a94d65d2
Bump SeaQuery and SeaSchema to new latest RC version (#1661) 2023-05-18 16:51:13 +08:00
Billy Chan
381e175847
Test CRUD on bit datatype (#1612) 2023-05-03 12:41:52 +08:00
Billy Chan
d514b511a4
Showcase how to define entity with dynamic table name (#1622) 2023-05-03 11:12:23 +08:00
Billy Chan
e6b6629733 Revert SeaORM prelude
Add `stream_partial_model` to `Select<E>` and `SelectTwo<E,F>`

Minor refactoring

fmt

Add `into_partial_model` to `Cursor<S>`

refactoring

Add test cases

Fix test cases

More test cases

Move partial_model tests
2023-04-26 18:28:53 +08:00
ForzenString
744e063222 add SelectColumns only modify select columns
add `PartialModelTrait` for a part of model

re-export `PartialModelTrait`

cargo fmt

add fn`into_partial_model` on `Select`&`SelectTwo`

add `DerivePartialModel` to impl `PartialModel`

add macro `DerivePartialModel` to `sea-orm`

disambiguate `SelectColumns` function

fix macro error

cargo fmt && cargo clippy

move `SelectColumns` from helper.rs to traits.rs

cargo fmt

Reduce nest hell of load attribute argument fetch

 test `DerivePartialModel`  input parse

`DerivePartialModel` not derive with generic

fix `DerivePartialModel` code generate error

remove unused use

cargo fmt

add `into_partial_model` for `SelectTwoMany`
2023-04-26 18:28:44 +08:00
Billy Chan
6833529441
feat: String parameters accept any Into<String> (#1439) 2023-04-11 12:51:51 +08:00
Iskandarov Lev
6ae515961c
implemented (#1464) 2023-04-11 11:23:14 +08:00