1013 Commits

Author SHA1 Message Date
Jesper Axelsson
18800b6e2a Only set features from features... 2020-04-17 23:03:46 -07:00
Jesper Axelsson
c1f17c75d2 Add suport for sqlite 2020-04-17 23:03:46 -07:00
Jesper Axelsson
961ade18d0 Moved all migration code for postgres behind traits 2020-04-17 23:03:46 -07:00
Jesper Axelsson
b20c6a2e09 Move migration code to their own files 2020-04-17 23:03:46 -07:00
Jesper Axelsson
93135c51f4 Start supporting more databases 2020-04-17 23:03:46 -07:00
Jesper Axelsson
42213b9937 Add feature check for database 2020-04-17 23:03:46 -07:00
Jesper Axelsson
5295389fdf Setup features 2020-04-17 23:03:46 -07:00
Jesper Axelsson
36301f6698 Started to abstract the postgres database 2020-04-17 23:03:46 -07:00
Ryan Leckey
145218f116 Merge branch 'shssoichiro-snake-case-support' 2020-04-17 22:52:11 -07:00
Ryan Leckey
230eeef940 Merge branch 'snake-case-support' of git://github.com/shssoichiro/sqlx into shssoichiro-snake-case-support 2020-04-17 22:51:52 -07:00
Josh Holmer
16229fd0ad Add basic query logging
Prints each query performed at DEBUG level,
along with a timing of how long the query took
to execute.

Slow queries will be printed at WARN level.
Currently the slow query threshold is
hardcoded to 1 second.
2020-04-17 22:49:33 -07:00
George Kaplan
7df6d4dbcf undo URL percent-encoding for SQLite connection strings 2020-04-17 18:23:33 -07:00
Samani G. Gikandi
45744e8033 Updates CI workflow for realworld
* Moves realworld into a separate file since it's long
* Adds checkout, db provisioning, and build steps for postgres and
  sqlite
2020-04-17 12:42:22 -07:00
Samani G. Gikandi
841d9a7f45 Changes PKs in realworld postgres to SERIAL
`GENERATED` was added in Postgres 12 and we test as far back as 9
2020-04-17 12:42:22 -07:00
Samani G. Gikandi
9fb523d4e8 Runs rustfmt across realworld 2020-04-17 12:42:22 -07:00
Samani G. Gikandi
8138a26b61 Finishes realworld example implementation
* Adds tables for  storing articles, tags, favorites, and comments.
* Implements all remaining web APIs (articles, tags, profiles, etc)

* Refactors `Provide` traits into
* `ProvideAuthn` is used to store/retrieve user info
* `ProvideData` is used to retrieve application data
* ` Provide` traits are now implemented on Connections instead of Pools
* Introduces `Db` trait that encapsulates DB connections

* Cleans up endpoint functions
2020-04-17 12:42:22 -07:00
Samani G. Gikandi
7038dd8ab2 Refactors realworld example with multi DB support
**General**

* Moves `examples/postgres/realworld` to `examples/realworld`
* The app is now architected to support multiple DBs
* Adds feature flags for `sqlite` and `postgres` to allow user to choose
  which backend to use

    *NOTE* Currently it is not possible to compile with `postgres` and `sqlite`
      enabled as we are using the `query!` and `query_as!` macros and they
      seem to get unhappy.

* Adds CLI flags for picking the DB backend to use at runtime
* Adds schema file and implementation for SQLite for `/api/user` routes
* Adds stub routes and trait for articles and Articles entity

**Changes**

* We now use i32 instead of i64 as the user_id to get around some quirks
  w/ the SQLite driver.
* Reimplements existing route handlers w/ an error handling shim so we can use
  Try inside the biz logic
* *FIX* Adds a `user` key to the register user body to conform w/ realworld's
  API specs

APIs were functionally tested using realworld's API test script
  (https://github.com/gothinkster/realworld/tree/master/api#authentication)
2020-04-17 12:42:22 -07:00
Josh Holmer
8b78680d9c Add snake_case rename support for Type macro
I encountered a use case while converting a project
from Diesel to sqlx, where I had a custom Postgres enum
which included a snake case field name:

```rust
pub enum JobStatus {
    NotRun,
    Finished,
    Failed,
}
```

Which translates to:

```sql
CREATE TYPE job_status AS ENUM ('not_run', 'finished', 'failed');
```

This is likely to be a semi-common use case,
so this commit adds snake case support for enums
via the `#[sqlx(rename_all = "snake_case")]` attribute.
2020-04-17 03:59:19 -04:00
meh
2fb38dd0c1 Derive all traits and impl Deref and AsRef for types::Json 2020-04-16 11:00:31 -07:00
meh
bfc52ca2f4 Add query_unchecked and query_file_unchecked macros 2020-04-16 09:54:09 -07:00
Jesper Axelsson
c3cc146e7c Update README.md 2020-04-15 08:26:50 -07:00
Jesper Axelsson
c6e9b2739b Formatting 2020-04-13 14:36:42 -07:00
Jesper Axelsson
719b04b61e Add drop and create database 2020-04-13 14:36:42 -07:00
Jesper Axelsson
3ec97c51b1 Setup database commands 2020-04-13 14:36:42 -07:00
Jesper Axelsson
35bcfd60c3 Create database based on connection string 2020-04-13 14:36:42 -07:00
Jesper Axelsson
9a765e4e86 Use anihow 2020-04-13 14:36:42 -07:00
Austin Bonander
f00b7b48e1 add regression test for Map::fetch() being Unpin 2020-04-13 14:17:37 -07:00
Josh Holmer
8deb5549b3 Fix missing derive in Readme example 2020-04-13 13:41:29 -07:00
Maksim Vykhota
5865635a80 fix 'fetch_all' typo 2020-04-11 04:21:38 -07:00
Austin Bonander
80eb2cc7d2 make the stream returned from Map::fetch() Unpin
closes #244
2020-04-11 03:04:21 -07:00
Ryan Leckey
90fd35745c Prepare v0.3.4 v0.3.4 2020-04-10 15:56:13 -07:00
xiaopengli89
c40288a8b4 Mysql/DECIMAL: add to CI 2020-04-10 15:35:58 -07:00
xiaopengli89
5711e1cc94 refactor: mysql decimal value is just ascii str 2020-04-10 15:35:58 -07:00
xiaopengli89
d50405743b add integration tests mysql-types.rs/decimal 2020-04-10 15:35:58 -07:00
xiaopengli89
229635771a fix: test 2020-04-10 15:35:58 -07:00
xiaopengli89
771d423c6f fix: change u8::MAX to std::u8::MAX 2020-04-10 15:35:58 -07:00
xiaopengli89
401ffd19e6 add test_encode_decimal, test_decode_decimal 2020-04-10 15:35:58 -07:00
xiaopengli89
b354ed430d implement DECIMAL type support for mysql 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
cd6735b5d7 fix(sqlite): handle empty statements, fixes #231 2020-04-08 02:13:37 -07:00
Ryan Leckey
b3fd720aad test(sqlite): add failing test to illustrate #231 2020-04-08 01:28:30 -07:00
Ryan Leckey
72bd933e41 add MapRow impls; closes #228 2020-04-08 01:24:57 -07:00
Kristy Brambila
0e61642165 Make postgres type name resolution case-insensitive 2020-04-08 01:22:37 -07:00
Ryan Leckey
466b6d6bed cargo-sqlx: update SQLx to v0.3 2020-04-07 15:55:06 -07:00
sid
012c186069 support rename attribute in FromRow macro 2020-04-07 14:49:34 -07:00
Ryan Leckey
543f89d0eb Merge branch 'JesperAxelsson-feature/cargo-sqlx-migrate' 2020-04-07 14:32:25 -07:00
Ryan Leckey
70387214a9 Merge branch 'feature/cargo-sqlx-migrate' of git://github.com/JesperAxelsson/sqlx into JesperAxelsson-feature/cargo-sqlx-migrate 2020-04-07 14:32:10 -07:00
Lewis Belcher
903de3e8d8 Update README.md
Simple terminology fix.
2020-04-07 04:11:11 -07:00
kosyak
6c9241a3a9 Fixed types of variables that interact with libsqlite3 2020-04-07 04:10:47 -07:00