Commit graph

379 commits

Author SHA1 Message Date
Julius de Bruijn
a4dc3dfbd7 Add a test showing a bug in describe/execute combo 2020-07-24 07:24:23 -07:00
Julius de Bruijn
590f97df4a Caching describe 2020-07-24 07:24:23 -07:00
Raphaël Thériault
435445fbd0 Edit migrator to make it possible to create static instances 2020-07-23 17:54:05 -04:00
Raphaël Thériault
92646e00b8 Fix migrate! and add migration test 2020-07-23 17:46:27 -04:00
Austin Bonander
94aa698581
refactor(macros): remove ResultExt and macro_result!() 2020-07-21 21:19:31 -07:00
Ryan Leckey
ee4d9b5412 fix(postgres): use the element type info from the protocol if available for array element decoding
fixes #537
2020-07-20 23:53:18 -07:00
Ryan Leckey
ae8800ccc4 feat(postgres): add () for VOID in macro resolution 2020-07-20 23:12:43 -07:00
Ryan Leckey
cd4e8dc1cb feat(mysql): support configuring the active charset and collation (via an automatic SET NAMES) 2020-07-20 23:07:22 -07:00
Ryan Leckey
cf78472d6d fix(mysql): gate com_stmt_execute encode on non-empty params, not non-null params 2020-07-20 21:49:30 -07:00
Ryan Leckey
96b76dc737 update todo examples to 0.4 and use migrations
* update tests/x.py

 * add examples/x.py
2020-07-18 05:43:16 -07:00
Ryan Leckey
14ecf5cbc4 test: make --target a prefix match and add --target-exact the old exact match 2020-07-18 03:26:55 -07:00
Ryan Leckey
9400a81cb0 test: switch tests/x.py to use host rustc for running tests 2020-07-18 03:18:25 -07:00
Ryan Leckey
f345c23e51 fix(mssql): handle multi-chunk packets
fixes #523
2020-07-17 06:08:36 -07:00
Ryan Leckey
9befdc81bf test: add a regression test for the bugs discovered with #527 2020-07-17 04:56:58 -07:00
Ryan Leckey
fa40e9e55f implement support for postgres TIMETZ type
Co-authored-by: Julius de Bruijn <julius+github@nauk.io>
2020-07-17 03:22:40 -07:00
Ryan Leckey
f4eb968c8d test(sqlite): add DB parameter to Decode invocation 2020-07-17 03:22:40 -07:00
Ryan Leckey
6949b84e8c style: rustfmt 2020-07-15 02:31:57 -07:00
Ryan Leckey
9b956c0d2c fix(postgres): support the VOID type, as () 2020-07-15 02:16:08 -07:00
Ryan Leckey
25b8fc7c04 fix(sqlite): support column types changing per row 2020-07-15 02:05:00 -07:00
Ryan Leckey
1247daec83 test: fix spurious ? in sqlite test 2020-07-14 08:52:42 -07:00
Ryan Leckey
54c857b448 fix some remaining usage of PoolOptions 2020-07-14 06:33:36 -07:00
Ryan Leckey
793f247604 refactor: PoolOptions::new() takes no parameters and the final .connect method takes the URI 2020-07-14 06:07:29 -07:00
Ryan Leckey
00137d4a04 feat: add sqlx::Done and return from Executor::execute()
+ Done::rows_affected()

 + Done::last_insert_id()
2020-07-14 04:31:25 -07:00
Ryan Leckey
93cab2a197 test: more pool usage adjustments 2020-07-12 05:02:40 -07:00
Ryan Leckey
fc682fa991 fix: adjust pool usage in tests and examples 2020-07-12 04:42:48 -07:00
OriolMunoz
993352e9d4 Support for #[sqlx(default)] 2020-07-12 03:57:17 -07:00
Mike Ledger
e731836e48 rust fmt wibble 2020-07-09 12:34:19 -07:00
Mike Ledger
03fcfc8562 concat test 2020-07-09 12:34:19 -07:00
Julius de Bruijn
f246d41aed Fixed an overflow with a negative scale 2020-07-09 12:32:19 -07:00
Julius de Bruijn
245d53e484 Test Decimal conversions in my and pg 2020-07-09 12:32:19 -07:00
Julius de Bruijn
e3b3806db5 Handle ParameterStatus in PgStream 2020-07-06 05:56:10 -07:00
Ryan Leckey
41df13ba5a test(postgres): fix unreliable test that depends on the sequence number 2020-07-05 04:40:13 -07:00
Ryan Leckey
8d188c5f1a feat: expose column information on Row
- add database-specific Column types: MySqlColumn, PgColumn, etc.
 - add Row::columns() -> &[DB::Column]
 - add Row::column(I) and Row::try_column(I)
2020-07-05 03:48:36 -07:00
Ryan Leckey
3b503a7764 feat(sqlite): clean up chrono support, add support for NaiveTime and NaiveDate 2020-07-04 05:51:46 -07:00
Ryan Leckey
7d22c0917f Merge remote-tracking branch 'meteficha/felipesere-rebased' 2020-07-04 04:37:11 -07:00
agentsim
7810f7dcdd
Sqlite Collation Support (#446)
* Sqlite Collation Support

Adds a method create_collation to SqliteConnection.
Adds a unit test confirming the collation works as expected.

* Fix formatting

* Address feedback

Co-authored-by: Ryan Leckey <ryan@launchbadge.com>
2020-07-04 04:30:40 -07:00
Ryan Leckey
aaa8b25050 test(sqlite): add a couple macro expression tests 2020-07-04 04:13:53 -07:00
Ryan Leckey
d112c4d807 feat(sqlite): support expressions and multiple no-data statements in the macros 2020-07-04 04:06:43 -07:00
Ryan Leckey
0def87b689 fix(derives): lift requirement of Copy + Clone on weak enums 2020-07-04 03:14:42 -07:00
Ryan Leckey
6a251efb65 fix(mysql): enum type derive and column overrides need to deref before eq 2020-07-04 02:59:56 -07:00
Ryan Leckey
3a8dc0e211 fix(tests): prevent postgres::pool_smoke_test from starving executor 2020-07-03 05:59:20 -07:00
Ryan Leckey
0824723765 fix: handle zero dates in MySQL, emit as Option::None (treat as NULL) 2020-07-03 05:50:06 -07:00
Julius de Bruijn
b3db51cdfc Implement a proper type for money 2020-07-03 03:57:20 -07:00
Ryan Leckey
4c5ea7af77 Merge remote-tracking branch 'dimtion/pginterval' 2020-07-02 23:35:05 -07:00
Ryan Leckey
0b2844bf39 feat(any): implement ColumnIndex<AnyRow> for &str to enable FromRow for the Any driver
closes #464
2020-07-02 23:28:53 -07:00
Ryan Leckey
222cd688a4 feat(sqlite): enable configuration of journal_mode and foreign_keys and default to WAL and ON 2020-07-02 23:18:14 -07:00
Ryan Leckey
5d6516da68 fix: re-add MapRow and TryMapRow to fix HRTB normalization when more than one driver is in-use 2020-07-02 23:00:46 -07:00
Ryan Leckey
c7c46f237b fix(sqlite): argument bind for sqlite is 1-indexed
fixes #467
2020-07-02 22:52:33 -07:00
Ryan Leckey
33ab2b9049 style: rustfmt 2020-07-02 22:38:23 -07:00
Ryan Leckey
1a7480774b fix(postgres): after closing a statement, the connection should await CloseComplete 2020-07-02 22:37:04 -07:00
Peter Maatman
eda0b7dea4 mysql: Fix decoding of TIME '00:00:00.000000'
Fixes #418
2020-06-29 04:33:25 -07:00
Ryan Leckey
e4005bb53d fix(mssql): handle errors without breaking the stream 2020-06-27 20:46:25 -07:00
Ryan Leckey
cfa833fa0d fix(sqlite): fallback to storage class when typing expressions and infer INTEGER as i64 2020-06-27 19:17:46 -07:00
Loïc Carr
71cb68b2f4 feat(postgres) Create bindings for PgInterval 2020-06-27 17:36:06 -07:00
Felipe Lessa
c827c72808
FixedOffset for SQLite + Local test. 2020-06-27 21:59:49 +01:00
Felipe Lessa
f0adeae39e
Add sqlite chrono tests. 2020-06-27 12:08:16 +01:00
Ryan Leckey
a7117dd71b feat(any): introduce the Any database driver which enables choosing the database driver at runtime 2020-06-27 04:07:40 -07:00
Felipe Lessa
364845e530
Update tests/sqlite/setup.sql to match current tests. 2020-06-27 09:11:02 +01:00
Ryan Leckey
7beceba832 fix(sqlite, test): column overrides still have runtime type checking, use the correct Rust type to match the sql type 2020-06-25 05:34:52 -07:00
Julius de Bruijn
2c2a277666 Caching methods in Connection 2020-06-25 10:44:05 +02:00
Julius de Bruijn
eba82e3fc1 LRU caching for SQLite 2020-06-24 19:46:32 +02:00
Julius de Bruijn
5d64310004 LRU caching for PostgreSQL 2020-06-24 19:01:54 +02:00
Julius de Bruijn
2b6f242a22 LRU statement cache for MySQL 2020-06-24 16:57:06 +02:00
Austin Bonander
36a53b44cd fix(macros): don't emit typechecking code for explicit type overrides on bind params 2020-06-21 06:06:53 -07:00
Austin Bonander
f2515e2472 feat(macros): support nullable column override 2020-06-21 06:06:53 -07:00
Austin Bonander
029ba24cad chore(macros): add tests for bind parameter overrides 2020-06-21 06:06:53 -07:00
Austin Bonander
7d3d708d92 chore(macros): add test for column overrides for SQLite 2020-06-21 06:06:53 -07:00
Austin Bonander
1a250976ba chore(macros): add test for column overrides for MySQL 2020-06-21 06:06:53 -07:00
Austin Bonander
eb831382e5 feat(macros): type override annotations for columns 2020-06-21 06:06:53 -07:00
Ryan Leckey
efc4df3eea test: state only version 3 for docker-compose 2020-06-21 04:35:28 -07:00
Ryan Leckey
8800a40979 test: tokio or actix should import tokio in pool_smoke_test 2020-06-21 04:34:29 -07:00
Ryan Leckey
9abdd7e408 style: rustfmt 2020-06-21 04:08:17 -07:00
Ryan Leckey
7c4c185698 chore: update dependencies 2020-06-21 03:55:31 -07:00
Ryan Leckey
e7e2f5b37a fix: implement transparent Serialize and Deserialize for Json<_> 2020-06-21 03:55:31 -07:00
Peter Maatman
90242494a8 test: expose missing trait bounds for Json<Vec<x>> 2020-06-21 03:55:31 -07:00
Ryan Leckey
6cfe5ac811 refactor: tweak type name display to use TypeInfo::name 2020-06-21 03:55:31 -07:00
Daniel Akhterov
639e10248e
feat: add boolean support to sqlx-macros/mssql 2020-06-16 13:40:53 -07:00
Daniel Akhterov
80d545109b
feat: implement BIT support in MSSQL 2020-06-15 22:49:33 -07:00
Ryan Leckey
c9f3e1adca feat(postgres): add support for built-in range types and allow derives to handle custom range types
Co-authored-by: Caio <c410.f3r@gmail.com>
2020-06-12 15:33:19 -07:00
Caio
d4329e98d4 refactor: prepare to support postgres ranges
- Remove Type bound from Encode + Decode which removes the defaults 
   for produces() and accepts(). This allows custom type implementations
   to be more flexible.
2020-06-12 15:33:19 -07:00
Ryan Leckey
a2c55b9f31 fix(mysql): tweak JSON type so it accepts BINARY in addition to CHAR (and make tests pass in MySQL 5.5) 2020-06-10 00:43:14 -07:00
Peter Maatman
2a5ea2f71b mysql: always use column alias when available
If a query has a column alias available we should use that name instead
of the column name.

Fixes #385
2020-06-10 00:42:58 -07:00
Ryan Leckey
e1d22a1840 fix(core): async-stream crate seems to lose the stream if the stream owns the object we are streaming
hand-rolled a copy of the idea behind AsyncStream and things seem to work
2020-06-09 02:16:47 -07:00
Peter Maatman
2677046a3b test: add test case for fetch_all bug with pool 2020-06-08 02:36:17 -07:00
Ryan Leckey
e54d030381 fix(mysql): str should produce VARCHAR not BLOB 2020-06-08 02:30:21 -07:00
Ryan Leckey
e001815a18 test: fix non-repeatable postgres macro test 2020-06-08 00:18:53 -07:00
Ryan Leckey
f2885f84a7 fix(mssql): handle NULL values 2020-06-07 16:30:07 -07:00
Ryan Leckey
6497d67b6a feat(mssql): add macro support 2020-06-07 16:29:46 -07:00
Ryan Leckey
a0ccc135aa style(mssql): rename MsSql to Mssql as MSSQL is not written MsSQL 2020-06-07 05:39:12 -07:00
Ryan Leckey
55a59121ee test: small fix to sql in json test 2020-06-07 04:07:33 -07:00
Ryan Leckey
53c074130f Merge remote-tracking branch 'origin/ab/macro-fixes' 2020-06-07 02:35:12 -07:00
Ryan Leckey
ef2527ff3e feat(mssql): fix a few bugs and implement Connection::describe 2020-06-07 02:00:31 -07:00
Ryan Leckey
559169cc79 refactor(mssql): clean up unused imports and other warnings 2020-06-07 02:00:13 -07:00
Ryan Leckey
18ae43aae8 test: fix docker-compose file for postgres 2020-06-07 02:00:13 -07:00
Ryan Leckey
12c1137d91 feat(mssql): add support for f32 and f64 2020-06-07 02:00:13 -07:00
Ryan Leckey
2a272bdd59 feat(mssql): setup type tests for MSSQL and add support for all the int types 2020-06-07 02:00:13 -07:00
Ryan Leckey
434bfaa76a feat(mssql): handle stream flushing 2020-06-07 02:00:13 -07:00
Ryan Leckey
c64122c03f feat(mssql): implement parameterized queries 2020-06-07 02:00:13 -07:00
Ryan Leckey
9a701313bc feat(mssql): implement enough to get simple queries working
Co-authored-by: Daniel Akhterov <akhterovd@gmail.com>
2020-06-07 02:00:12 -07:00
Ryan Leckey
8c42d7fcc0 chore: setup MSSQL and DB2 in docker-compose 2020-06-07 02:00:12 -07:00
Austin Bonander
0652864315
fix(macros): reintroduce and fix test for macros in SQLite 2020-06-05 21:16:14 -07:00
Austin Bonander
80b4e2fca6
fix(macros): reintroduce and fix macro tests for MySQL 2020-06-05 21:02:24 -07:00
Austin Bonander
bddb2e560f
fix(macros): fix macros for Postgres 2020-06-05 20:28:21 -07:00
Austin Bonander
e3dbd58bf2 PgConnection: use more obvious/safer query for ping() 2020-06-05 20:13:20 -07:00
Ryan Leckey
0c80aa4f2c test: add a test to prove #363 works 2020-06-01 16:58:48 -07:00
Ryan Leckey
884b523d43 fix: tests/x.py doesn't need to worry about user permissions on windows 2020-06-01 05:23:31 -07:00
Ryan Leckey
e08f05b879
feat: re-introduce error downcasting 2020-05-30 17:51:56 -07:00
Ryan Leckey
e5b6047009
feat: introduce docker-compose based testing for running locally against many database combinations 2020-05-30 17:51:55 -07:00
Blaine Bublitz
28c639fd84 Seems like postgres needs tests like this 2020-05-20 20:33:03 -07:00
Blaine Bublitz
03ba5ca434 I think postgres needs this 2020-05-20 20:33:03 -07:00
Blaine Bublitz
2ffbe2f06e More copy-paste errors 2020-05-20 20:33:03 -07:00
Blaine Bublitz
84f4ab5799 Attempt to fix copy-paste errors 2020-05-20 20:33:03 -07:00
Blaine Bublitz
e5b6754ac6 fix failures 2020-05-20 20:33:03 -07:00
Blaine Bublitz
7283e690ff rustfmt 2020-05-20 20:33:03 -07:00
Blaine Bublitz
168ce9bed0 Attempt to add integration tests 2020-05-20 20:33:03 -07:00
Austin Bonander
c285e28670 fix and test handling of 0 for BigDecimal in Postgres/MySQL
closes #283
2020-04-28 11:54:41 -07:00
Austin Bonander
a7d039931c fix UI tests
looks like the `.stderr` file for a SQLite UI test never got added, and notes on errors in other tests changed slightly
2020-04-27 19:43:54 -07:00
Peter Maatman
30d13174ea mysql: Add JSON support 2020-04-19 15:58:47 -07:00
Austin Bonander
f00b7b48e1 add regression test for Map::fetch() being Unpin 2020-04-13 14:17:37 -07:00
xiaopengli89
d50405743b add integration tests mysql-types.rs/decimal 2020-04-10 15:35:58 -07:00
Ryan Leckey
52408f3cbf test(postgres): make test_enum_type more resilient 2020-04-10 14:22:18 -07:00
Ryan Leckey
d360f682f8 fix(postgres): guarantee the type name on a PgTypeInfo to always be set
fixes #241
2020-04-10 13:37:08 -07:00
Ryan Leckey
b3fd720aad test(sqlite): add failing test to illustrate #231 2020-04-08 01:28:30 -07:00
sid
012c186069 support rename attribute in FromRow macro 2020-04-07 14:49:34 -07:00
Ryan Leckey
4dc634f8b5 postgres: add a test to prove Type derive works for structs and fix the issue with it
fixes #219
2020-04-01 16:40:04 -07:00
sid
40f11ebb77 Process keyword fields correctly in FromRow macro
This PR fixes the the incorrect handling of keywords fields of a struct in the FromRow macro.
Currently a struct with a field like 'r#type' will try to read values from a column with the exact same name with r# prefix. With this change this field will now map to a database column with the correct name 'type' without the r# prefix.
2020-03-30 19:30:50 +05:30
Ryan Leckey
5fa11da353 use sqlx_test over connect fn in test 2020-03-29 14:40:02 -07:00
Ryan Leckey
c59d7aeebe macro tests: update for null inferrence 2020-03-29 01:33:12 -07:00
Austin Bonander
fb50968ec7 update schema in SQLite test DB 2020-03-28 17:50:27 -07:00
Austin Bonander
4b51c16cce MySQL: tweak macro test a bit 2020-03-28 17:50:27 -07:00
Austin Bonander
4ffa7f0e01 SQLite: implement column nullability checking 2020-03-28 17:50:27 -07:00
Austin Bonander
6fde5a2579 implement nullability on macro output, test postgres 2020-03-28 17:50:27 -07:00
Oliver Bøving
bcb3959379
Add array of uuid, chrono, time, bigdecimal, and ipnetwork as well as JsonValue to query macro (#154)
* Add array of uuid, chrono, time, bigdecimal, and ipnetwork to query macro

* Comment out tests for arrays of BigDecimal

Currently arrays of BigDecimal doesn't in query macros compile.
As all of the other types work just fine, BigDecimal is simply omitted.

* Add serde_json::Value to query macros

This also adds serde_json as an optional dependency to sqlx_macros along
side a new json feature flag.
2020-03-28 17:28:47 -07:00
Ryan Leckey
2f80621279 Add query_as_unchecked! and query_file_as_unchecked! to use the macro system with unchecked input and output 2020-03-27 16:37:28 -07:00
Austin Bonander
e594a7fdca Postgres: don't cache failed statement 2020-03-27 15:54:28 -07:00
Ryan Leckey
3103d50be8 postgres: implement PgTypeInfo::with_name
- remove PgTypeInfo::with_oid
 - use a new PgRawBuffer type instead of Vec<u8> for encoding
2020-03-26 19:29:49 -07:00
Ryan Leckey
c6db69574b postgres: remove PgTypeInfo::type_name() 2020-03-26 19:16:54 -07:00
Austin Bonander
3436ede2d3 fix some remaining fallout from Result refactor 2020-03-25 22:33:03 -07:00
Ryan Leckey
2274b69556 postgres: support "CHAR" and OID 2020-03-25 04:46:17 -07:00
Ryan Leckey
50a9120efb mysql: use the correct integer width 2020-03-25 04:31:38 -07:00
Ryan Leckey
6049f976f9 opt out of compatible type check for null values 2020-03-25 04:25:38 -07:00
Ryan Leckey
7ab772ea80 postgres: simplify JSON support to just Json<T> 2020-03-25 04:20:35 -07:00
Ryan Leckey
ad2cf1676f mysql: tweak type equivalence rules to try and support both rust best practices but still be compatible with the loose types of mysql 2020-03-25 03:56:39 -07:00
Ryan Leckey
50928b06b8 mysql: implement type compatible checks 2020-03-25 03:24:43 -07:00
Ryan Leckey
129efcd367 implement a runtime type compatibility check before decoding values 2020-03-25 02:07:17 -07:00
Ryan Leckey
1dc582edd0 postgres: have PgValue remember its type OID
this is in preparation of doing type compatibility checks
2020-03-25 01:46:13 -07:00
Ryan Leckey
63aa3e8f0f add support for VARCHAR and BPCHAR in postgres 2020-03-24 12:49:52 -07:00
Ryan Leckey
f83e0296cc don't use now private module runtime in tests 2020-03-24 03:13:12 -07:00
Ryan Leckey
dcea3f0586 fix FromRow derive to take &Row 2020-03-24 03:08:58 -07:00
Ryan Leckey
3ecc2e06ba Run rustfmt (small issue in a test) 2020-03-23 21:24:28 -07:00