155 Commits

Author SHA1 Message Date
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
Blaine Bublitz
33915ae3ad Add uppercase support for Type macro 2020-05-20 20:33:03 -07:00
Ryan Leckey
cbccd68963
chore: prepare v0.3.5 2020-05-06 03:30:35 -07:00
Dan B
e7c1486005 Add support for crate specific .env files
This change will attempt to load an .env file from CARGO_MANIFEST_DIR, if it exists.

For backwards compatibility, if the .env file does not exist, we will fall back to default dotenv behaviour.

Resolves #267
2020-04-24 15:40:20 -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
bfc52ca2f4 Add query_unchecked and query_file_unchecked macros 2020-04-16 09:54:09 -07:00
Ryan Leckey
90fd35745c Prepare v0.3.4 2020-04-10 15:56:13 -07:00
xiaopengli89
b354ed430d implement DECIMAL type support for mysql 2020-04-10 15:35:58 -07:00
sid
012c186069 support rename attribute in FromRow macro 2020-04-07 14:49:34 -07:00
Ryan Leckey
e7ace2adc7 Prepare v0.3.3 2020-04-01 18:24:08 -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
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
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
fc3d06bf9b Prepare v0.3.0 2020-03-29 16:27:41 -07:00
Ryan Leckey
3d590c5d66 macros: remove try_unwrap_optional from _unchecked codepath 2020-03-29 01:27:57 -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
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
Austin Bonander
3436ede2d3 fix some remaining fallout from Result refactor 2020-03-25 22:33:03 -07:00
Ryan Leckey
a90ff10a27 Prepare v0.3.0-alpha.2 2020-03-25 04:58:22 -07:00
Ryan Leckey
2274b69556 postgres: support "CHAR" and OID 2020-03-25 04:46:17 -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
dcea3f0586 fix FromRow derive to take &Row 2020-03-24 03:08:58 -07:00
Ryan Leckey
43a72657f9 add a hack so bigdecimal can be the package name and the feature name 2020-03-24 02:56:14 -07:00
Ryan Leckey
0182ce92f2 make sqlx_core::runtime private and add a runtime module to sqlx-macros 2020-03-24 01:19:03 -07:00
Ryan Leckey
d646a1d509 remove unused import in derives/row 2020-03-23 22:07:06 -07:00
Ryan Leckey
5ada3f3ae6 Implement #[derive(FromRow)] 2020-03-23 21:18:03 -07:00
Ryan Leckey
4a98a51a19 Merge remote-tracking branch 'utter-step/time-rs' 2020-03-21 01:25:00 -07:00
Daniel Akhterov
cbdc1bbfb2 Refactor the error to be generic over database 2020-03-20 23:51:45 -07:00
Ryan Leckey
f562e919b7 Merge branch '1d-array-pg-support' of https://github.com/oeb25/sqlx into oeb25-1d-array-pg-support 2020-03-20 10:11:02 -07:00
Ryan Leckey
50c3e5fefb
Merge pull request #138 from PoiScript/master
postgres: ipnetwork support
2020-03-20 09:54:43 -07:00
Ryan Leckey
4f8ee0f08f
Merge pull request #139 from Freax13/fix-error-messages
use syn::Error for error messages
2020-03-20 09:52:14 -07:00
Tom Dohrmann
a944d99c1c support derives for sqlite 2020-03-20 10:21:15 +01:00
PoiScript
c9cca27e65 rename feature gate to ipnetwork 2020-03-20 10:19:14 +08:00
Tom Dohrmann
bd7d85a03e use syn:Error for error messages 2020-03-19 13:42:46 +01:00
Austin Bonander
33677e86a8 move PgNumeric[Sign], PgRecord[Encoder,Decoder] to hidden postgres::types::raw
fix errors
2020-03-18 19:36:54 -07:00
Austin Bonander
3cb42def3b macros: add support for Postgres + BigDecimal 2020-03-18 19:06:14 -07:00
Austin Bonander
94c40b3eb7 Postgres: implement numeric and BigDecimal support 2020-03-18 19:06:14 -07:00
Ryan Leckey
d1af2fe1b0 Prepare v0.3.0-alpha.1 2020-03-18 16:58:42 -07:00
Ryan Leckey
0a534792bb remove unused import in macros 2020-03-17 22:00:26 -07:00
Ryan Leckey
d380f4b4a8 remove is_null_type and use Option<TypeInfo> 2020-03-17 21:43:41 -07:00
Ryan Leckey
96f1dd76bc macros: sqlite: add support for bool 2020-03-17 21:33:14 -07:00
Austin Bonander
8328e07c97 macros + sqlite: fix error for null-typed columns 2020-03-17 21:10:19 -07:00
Ryan Leckey
ff722d0e62 Run rustfmt 2020-03-17 19:35:01 -07:00
Ryan Leckey
d77b2b1e97 derives: update for new Decode/Encode traits and extensively test in usage 2020-03-17 19:26:59 -07:00
Ryan Leckey
4fc5e65f5d derives: update transparent 2020-03-17 03:24:08 -07:00
Tom Dohrmann
62b591e63a use iterator change in expand_derive_strong_enum 2020-03-16 22:58:31 -07:00