Commit graph

102 commits

Author SHA1 Message Date
Ryan Leckey
7c4c185698 chore: update dependencies 2020-06-21 03:55:31 -07:00
Ryan Leckey
f8dc7284b9 chore: update dependencies 2020-06-21 03:55:31 -07:00
Ryan Leckey
e2ac01e190 chore: update dependencies 2020-06-13 08:54:38 -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
Ryan Leckey
6497d67b6a feat(mssql): add macro support 2020-06-07 16:29:46 -07:00
Daniel Akhterov
362a546484 feat(postgres): make sure username is ran through saslprep before sending to server 2020-06-07 02:34:41 -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
28636c1f5d feat(mssql): add support for string types including a framework for handling non-UTF8 data 2020-06-07 02:00:13 -07:00
Ryan Leckey
51ae9f00e7
chore: bump version to 0.4.0-pre 2020-05-30 23:15:52 -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
Ryan Leckey
2966b655fc
refactor(mysql): adapt to the 0.4.x core refactor 2020-05-30 17:48:10 -07:00
Ryan Leckey
757a930e21
refactor(core): remove the HRTB (higher rank trait bound) on Row in the aim of improving ergonomics
* removes the lifetime from Row

 * removes MySqlQueryAs, SqliteQueryAs, etc. (no longer needed)

 * introduce query_scalar

 * introduce Decode::accepts to allow overriding runtime type checking
   per-type (replaces TypeInfo::compatible)

 * introduce Encode::produces to allow overriding the encoded type per-value

 * adds a lifetime to Arguments (and introduce the HRTB HasArguments)
   to support zero-copy encoding with SQLite

 * renames Database::RawBuffer to HasArguments::ArgumentBuffer

 * introduce Connect::connect_with to provide an ConnectOptions type
   explicitly to opt-out of connection string parsing

 * introduce Value and ValueRef traits to allow decoding-deferred
   extraction of values from Rows

 * introduce Encode::encode_by_ref and change Encode::encode to take
   by-value to try and re-use memory where possible

 * use thiserror to generate sqlx::Error

 * [!] temporarily removes query logging

 * [!] temporarily removes transactions
2020-05-30 16:09:08 -07:00
Austin Bonander
7dae3dbf57 rename cargo-sqlx -> sqlx-cli
edit README
2020-05-30 16:02:37 -07:00
Austin Bonander
6b248e0d5f get offline macros working with todos example 2020-05-30 16:02:37 -07:00
Austin Bonander
21041ff55e implement cargo sqlx prepare
also organize code more clearly in `cargo-sqlx`
2020-05-30 16:02:37 -07:00
Austin Bonander
6913695588 add support for building in "decoupled" mode 2020-05-30 16:02:37 -07:00
Ryan Leckey
cbccd68963
chore: prepare v0.3.5 2020-05-06 03:30:35 -07:00
Milan Zivkovic
3edf84ae3d Todo API example using Actix-web and SQLx with PostgreSQL database 2020-04-30 21:16:45 -07:00
Josh Holmer
f73149a90f Format SQL queries when printing them to the logs
Before, the query would be formatted equivalent to the input string:

```
[2020-04-18T23:47:32Z DEBUG sqlx_core::postgres::executor] SELECT id, queue, ..., elapsed: 2.320µs

        SELECT id, queue, payload, status, priority, created_at, updated_at
    FROM jobs
    WHERE status = $1
    ORDER BY priority ASC, created_at ASC

```

After, the query is formatted cleanly and consistently:

```
[2020-04-19T00:30:18Z DEBUG sqlx_core::postgres::executor] SELECT id, queue, ..., elapsed: 2.280µs

    SELECT
      id,
      queue,
      payload,
      status,
      priority,
      created_at,
      updated_at
    FROM
      jobs
    WHERE
      status = $1
    ORDER BY
      priority ASC,
      created_at ASC

```

This uses the `sqlformat` crate, which was ported from the
Javascript `sql-formatter-plus` library specifically for this purpose.
2020-04-19 16:11:50 -07:00
Peter Maatman
1b04829c46 json: Refactor Encode/Decode for serde values to be generic for DB
Since the implementation of Encode and Decode for both mysql and
postgres on serde's Value and RawValue were practically the same they
were moved to the generic json module.
2020-04-19 15:58:47 -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
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
Ryan Leckey
90fd35745c Prepare v0.3.4 2020-04-10 15:56:13 -07:00
Ryan Leckey
466b6d6bed cargo-sqlx: update SQLx to v0.3 2020-04-07 15:55:06 -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
Ryan Leckey
e7ace2adc7 Prepare v0.3.3 2020-04-01 18:24:08 -07:00
Jon Pacheco
f4e4836fa6 Clone TODOs example for MySQL 2020-03-31 20:35:34 +01:00
Jon Pacheco
79a5e5e1d5 Clone TODOs example for SQLite
Differences to Postgres version:
- Minor changes to schema
- Add TODO: "RETURNING" isn't supported, so retrieve ID separately
2020-03-31 20:35:34 +01:00
Neeraj Jaiswal
c29fc5cccd Remove matches dependency and use matches macro from std 2020-03-31 18:01:06 +05:30
Ryan Leckey
a9fc05378e Prepare v0.3.2 2020-03-31 03:02:01 -07:00
Ryan Leckey
a84e1f6626 Prepare v0.3.1 2020-03-30 18:53:03 -07:00
Ryan Leckey
c6b0ceed34 update lockfile 2020-03-30 18:46:31 -07:00
Jon Pacheco
501ed887e3 Restructure examples folder 2020-03-31 00:35:07 +01:00
Ryan Leckey
fc3d06bf9b Prepare v0.3.0 2020-03-29 16:27:41 -07:00
Ryan Leckey
7a59e383bf Update lockfile 2020-03-29 14:29:55 -07:00
Jesper Axelsson
e577358686 Added migration tool to sqlx 2020-03-29 09:39:59 +02: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
78f2633b26 Update dependencies 2020-03-26 19:16:54 -07:00
Ryan Leckey
a90ff10a27 Prepare v0.3.0-alpha.2 2020-03-25 04:58:22 -07:00
Ryan Leckey
e2f90c8f85 Update dependencies 2020-03-23 22:07:38 -07:00
Ryan Leckey
4881e7dcee Update dependencies 2020-03-21 03:01:54 -07:00
Ryan Leckey
db543f8391 clean up Time impl, impl for text modes 2020-03-21 02:34:21 -07:00
Ryan Leckey
4a98a51a19 Merge remote-tracking branch 'utter-step/time-rs' 2020-03-21 01:25:00 -07:00
Ryan Leckey
05d8ac2747 Finish up JSON/JSONB support for Postgres
* implement for &serde_json::RawValue

 * sqlx::types::Json<T> is a common type that all JSON-compatible databases can implement for,
   postgres implements Json<T> as JSONB

 * sqlx::postgres::types::PgJson<T> resolves to JSON

 * sqlx::postgres::types::PgJsonB<T> resolves to JSONB
2020-03-21 01:16:34 -07:00
Oliver Bøving
b7e53e885a First draft of JSON/JSONB support for postgres
This introduces two new wrapper types `Json` and `Jsonb`, currently
exported by `sqlx::postgres::{Json, Jsonb}` and adds serde and
serde_json as optional dependencies, under the feature flag `json`.
Wrapping types in `Json[b]` that implement `serde::Deserialize` and
`serde::Serialize` allows them to be decoded and encoded respectivly.
2020-03-20 23:59:25 -07:00
PoiScript
3014ab4750 fix typo in Cargo.toml 2020-03-20 10:51:47 +08:00
PoiScript
060c5d2b66 postgres: ipnetwork support 2020-03-19 18:21:09 +08:00
Austin Bonander
979c5cc944 remove unnecessary comment and update Cargo.lock 2020-03-18 19:09:10 -07:00