Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnexpectedNullError when deserializing (Null,Boolean,Boolean) into Option<(a,b,c)> #2274

Closed
2 tasks done
Ten0 opened this issue Jan 22, 2020 · 1 comment
Closed
2 tasks done

Comments

@Ten0
Copy link
Member

Ten0 commented Jan 22, 2020

Setup

Versions

  • Rust: 1.40.0
  • Diesel: master (bd349ce)
  • Database: Postgresql
  • Operating System Linux

Feature Flags

  • diesel: "postgres", "r2d2", "serde_json", "chrono"

Problem Description

Hitting an unexpected UnexpectedNullError at runtime

What are you trying to accomplish?

    xxx::table
        .find(xxx_id)
        .inner_join(yyy::table)
        .left_join(zzz::table)
        .select((
            xxx::integer,
            (
                zzz::integer,
                zzz::nullable_integer.is_not_null(),
                yyy::nullable_integer
                    .is_not_null()
                    .or(zzz::nullable_enum.is_not_null()),
            )
                .nullable(),
        ))
        .get_result::<(Option<i32>, Option<(i32, bool, bool)>)>(db)?;

where postgres' tuple result of that query is NULL, NULL, FALSE, FALSE

What is the expected output?

Ok((None, None))

What is the actual output?

Err(DeserializationError(UnexpectedNullError))

Are you seeing any additional errors?

Stack trace of where this error ends up being triggered is:

  14: diesel::type_impls::integers::<impl diesel::deserialize::FromSql<diesel::sql_types::Integer,DB> for i32>::from_sql
             at /home/ten/Projects/diesel/diesel/src/type_impls/integers.rs:47
  15: diesel::type_impls::primitives::foreign_impls::_::<impl diesel::deserialize::FromSqlRow<__ST,__DB> for i32>::build_from_row
             at /home/ten/Projects/diesel/diesel/src/type_impls/primitives.rs:28 <-- This probably comes from that I'm actually using an intermediate type but it's unrelated to our issue: same thing happens when using directly an i32
  16: diesel::type_impls::tuples::<impl diesel::deserialize::FromSqlRow<(SA, SB, SC, SD),__DB> for (A, B, C, D)>::build_from_row
             at ./src/lib.rs:1
  17: diesel::type_impls::option::<impl diesel::deserialize::FromSqlRow<diesel::sql_types::Nullable<ST>,DB> for core::option::Option<T>>::build_from_row
             at /home/ten/Projects/diesel/diesel/src/type_impls/option.rs:98
  18: diesel::type_impls::tuples::<impl diesel::deserialize::FromSqlRow<(SA, SB),__DB> for (A, B)>::build_from_row
             at ./src/lib.rs:1
  19: <diesel::pg::connection::cursor::Cursor<ST,T> as core::iter::traits::iterator::Iterator>::next
             at /home/ten/Projects/diesel/diesel/src/pg/connection/cursor.rs:41

(replaced the return Err(UnexpectedNullError) of the not_none! macro by a panic to get the stack trace so I hope this error would not have been caught and handled, but it's pretty consistent with why i'd expect this error to trigger so I think this is the actual issue.

Checklist

  • I have already looked over the issue tracker for similar issues.
  • This issue can be reproduced on Rust's stable channel. (Your issue will be
    closed if this is not the case)

Solving

Digged into that stacktrace a bit, and found this:

impl<T, ST, DB> FromSqlRow<Nullable<ST>, DB> for Option<T>
where
T: FromSqlRow<ST, DB>,
DB: Backend,
ST: NotNull,
{
const FIELDS_NEEDED: usize = T::FIELDS_NEEDED;
fn build_from_row<R: crate::row::Row<DB>>(row: &mut R) -> deserialize::Result<Self> {
let fields_needed = Self::FIELDS_NEEDED;
if row.next_is_null(fields_needed) {
row.advance(fields_needed);
Ok(None)
} else {
T::build_from_row(row).map(Some)
}
}
}

where in particular, next_is_null is documented as making sure that "the next count columns are all NULL", hence the current behaviour.

Note: Just checking whether any of these columns is null is not satisfactory because we still want to deserialize 1, NULL into Option<i32, Option<i32>> as Some(1, None) and not just None.

Whether it should be solved

Clearly in my case whether these booleans are defined doesn't have any meaning if I couldn't join on the zzz table, so I'm very happy to not have access to them if just any of these fields is NULL, which is why I'm expecting this behaviour.

I can't think of a scenario where I'd prefer a runtime error: cases where I could unintentionally "forget" a field should be covered by the typing after the query: "Why can't I get the value of this field? Oh it's because it was packed in this Option...)

Ten0 added a commit to Ten0/diesel that referenced this issue Jan 22, 2020
Ten0 added a commit to Ten0/diesel that referenced this issue Jan 22, 2020
weiznich pushed a commit to Ten0/diesel that referenced this issue Jan 24, 2020
Ten0 added a commit to Ten0/diesel that referenced this issue Feb 17, 2020
weiznich added a commit to GiGainfosystems/diesel that referenced this issue Jun 12, 2020
Dynamically sized return values cannot know this value at compile
time, therefore we should not assume it here. Removing this constant
implies a few other changes:

* The implementation of `FromSqlRow<Nullable<ST>, DB> for Option<T>`
needs to change as it uses this value internally to skip all other
rows (incorrectly as noted in diesel-rs#2274). I've opted for correctly calling
`build_from_row` for all tuple elements in our tuple impls before
actually returning an error here. This comes with the slight overhead
of constructing all return types
* Sqlite functions need to know the argument count at compile time. To
support them I've introduced a new `StaticallySizedRow` that is
implemented for all diesel types that implemented `FromSqlRow` on
diesel 1.0 or used the `FromSqlRow` derive

Also added a test case for diesel-rs#2274

Fixes diesel-rs#2274
@weiznich
Copy link
Member

weiznich commented Jun 12, 2020

@Ten0 I've added a fix for this as part of #2182 in 9433438. Any input there would be welcome.

weiznich added a commit to GiGainfosystems/diesel that referenced this issue Jun 12, 2020
Dynamically sized return values cannot know this value at compile
time, therefore we should not assume it here. Removing this constant
implies a few other changes:

* The implementation of `FromSqlRow<Nullable<ST>, DB> for Option<T>`
needs to change as it uses this value internally to skip all other
rows (incorrectly as noted in diesel-rs#2274). I've opted for correctly calling
`build_from_row` for all tuple elements in our tuple impls before
actually returning an error here. This comes with the slight overhead
of constructing all return types
* Sqlite functions need to know the argument count at compile time. To
support them I've introduced a new `StaticallySizedRow` that is
implemented for all diesel types that implemented `FromSqlRow` on
diesel 1.0 or used the `FromSqlRow` derive

Also added a test case for diesel-rs#2274

Fixes diesel-rs#2274
weiznich added a commit to GiGainfosystems/diesel that referenced this issue Jun 26, 2020
(Sorry for the really large diff but this touches nearly all parts of
diesel)

This commit does in two things:
* Refactor our handling of nullable values. Instead of having a marker
trait for non nullable sql types we now indicate if a sql type is
nullable by using a associated type on a new fundamental trait named
SqlType. This allows us to reason if an type is nullable or not in a
much precise way without running in conflicting implementation
issues. This allows us to address diesel-rs#104 in a much more fundamental
way. (The correct way as mentioned there by sgrif).
* Refactor our handling of typed and untyped sql fragments. Instead of
having two separate code paths for `Queryable` (sql types known) and
`QueryableByName` (sql types not known) we now have only one code path
and indicate if a query is typed or untyped as part of the expression
sql type. This is required to address diesel-rs#2150. As part of this change we
unify `Queryable`, `QueryableByName` and `FromSqlRow` into only
`FromSqlRow`. Additionally we separate the static size component of
`FromSqlRow` to allow dynamically sized rows there (but only at the
last position for tuple impls.)

I should probably have implement those changes in different commits
but as both changes basically requiring touching most of our code base
this would have required much more work...

Both changes are theoretically big major breaking changes. For
application code I expect the actual breakage to be minimal, see the
required changes in `diesel_tests` and `diesel_cli` for examples. For
highly generic code I would expect quite a few required changes.

Additionally there are a few small drive by fixes.

Fixes diesel-rs#104
Fixes diesel-rs#2274
Fixes diesel-rs#2161
weiznich added a commit to GiGainfosystems/diesel that referenced this issue Jul 10, 2020
(Sorry for the really large diff but this touches nearly all parts of
diesel)

This commit does in two things:
* Refactor our handling of nullable values. Instead of having a marker
trait for non nullable sql types we now indicate if a sql type is
nullable by using a associated type on a new fundamental trait named
SqlType. This allows us to reason if an type is nullable or not in a
much precise way without running in conflicting implementation
issues. This allows us to address diesel-rs#104 in a much more fundamental
way. (The correct way as mentioned there by sgrif).
* Refactor our handling of typed and untyped sql fragments. Instead of
having two separate code paths for `Queryable` (sql types known) and
`QueryableByName` (sql types not known) we now have only one code path
and indicate if a query is typed or untyped as part of the expression
sql type. This is required to address diesel-rs#2150. As part of this change we
unify `Queryable`, `QueryableByName` and `FromSqlRow` into only
`FromSqlRow`. Additionally we separate the static size component of
`FromSqlRow` to allow dynamically sized rows there (but only at the
last position for tuple impls.)

I should probably have implement those changes in different commits
but as both changes basically requiring touching most of our code base
this would have required much more work...

Both changes are theoretically big major breaking changes. For
application code I expect the actual breakage to be minimal, see the
required changes in `diesel_tests` and `diesel_cli` for examples. For
highly generic code I would expect quite a few required changes.

Additionally there are a few small drive by fixes.

Fixes diesel-rs#104
Fixes diesel-rs#2274
Fixes diesel-rs#2161
weiznich added a commit to GiGainfosystems/diesel that referenced this issue Jul 16, 2020
(Sorry for the really large diff but this touches nearly all parts of
diesel)

This commit does in two things:
* Refactor our handling of nullable values. Instead of having a marker
trait for non nullable sql types we now indicate if a sql type is
nullable by using a associated type on a new fundamental trait named
SqlType. This allows us to reason if an type is nullable or not in a
much precise way without running in conflicting implementation
issues. This allows us to address diesel-rs#104 in a much more fundamental
way. (The correct way as mentioned there by sgrif).
* Refactor our handling of typed and untyped sql fragments. Instead of
having two separate code paths for `Queryable` (sql types known) and
`QueryableByName` (sql types not known) we now have only one code path
and indicate if a query is typed or untyped as part of the expression
sql type. This is required to address diesel-rs#2150. As part of this change we
unify `Queryable`, `QueryableByName` and `FromSqlRow` into only
`FromSqlRow`. Additionally we separate the static size component of
`FromSqlRow` to allow dynamically sized rows there (but only at the
last position for tuple impls.)

I should probably have implement those changes in different commits
but as both changes basically requiring touching most of our code base
this would have required much more work...

Both changes are theoretically big major breaking changes. For
application code I expect the actual breakage to be minimal, see the
required changes in `diesel_tests` and `diesel_cli` for examples. For
highly generic code I would expect quite a few required changes.

Additionally there are a few small drive by fixes.

Fixes diesel-rs#104
Fixes diesel-rs#2274
Fixes diesel-rs#2161
weiznich added a commit to GiGainfosystems/diesel that referenced this issue Jul 16, 2020
(Sorry for the really large diff but this touches nearly all parts of
diesel)

This commit does in two things:
* Refactor our handling of nullable values. Instead of having a marker
trait for non nullable sql types we now indicate if a sql type is
nullable by using a associated type on a new fundamental trait named
SqlType. This allows us to reason if an type is nullable or not in a
much precise way without running in conflicting implementation
issues. This allows us to address diesel-rs#104 in a much more fundamental
way. (The correct way as mentioned there by sgrif).
* Refactor our handling of typed and untyped sql fragments. Instead of
having two separate code paths for `Queryable` (sql types known) and
`QueryableByName` (sql types not known) we now have only one code path
and indicate if a query is typed or untyped as part of the expression
sql type. This is required to address diesel-rs#2150. As part of this change we
unify `Queryable`, `QueryableByName` and `FromSqlRow` into only
`FromSqlRow`. Additionally we separate the static size component of
`FromSqlRow` to allow dynamically sized rows there (but only at the
last position for tuple impls.)

I should probably have implement those changes in different commits
but as both changes basically requiring touching most of our code base
this would have required much more work...

Both changes are theoretically big major breaking changes. For
application code I expect the actual breakage to be minimal, see the
required changes in `diesel_tests` and `diesel_cli` for examples. For
highly generic code I would expect quite a few required changes.

Additionally there are a few small drive by fixes.

Fixes diesel-rs#104
Fixes diesel-rs#2274
Fixes diesel-rs#2161
weiznich added a commit to GiGainfosystems/diesel that referenced this issue Jul 16, 2020
(Sorry for the really large diff but this touches nearly all parts of
diesel)

This commit does in two things:
* Refactor our handling of nullable values. Instead of having a marker
trait for non nullable sql types we now indicate if a sql type is
nullable by using a associated type on a new fundamental trait named
SqlType. This allows us to reason if an type is nullable or not in a
much precise way without running in conflicting implementation
issues. This allows us to address diesel-rs#104 in a much more fundamental
way. (The correct way as mentioned there by sgrif).
* Refactor our handling of typed and untyped sql fragments. Instead of
having two separate code paths for `Queryable` (sql types known) and
`QueryableByName` (sql types not known) we now have only one code path
and indicate if a query is typed or untyped as part of the expression
sql type. This is required to address diesel-rs#2150. As part of this change we
unify `Queryable`, `QueryableByName` and `FromSqlRow` into only
`FromSqlRow`. Additionally we separate the static size component of
`FromSqlRow` to allow dynamically sized rows there (but only at the
last position for tuple impls.)

I should probably have implement those changes in different commits
but as both changes basically requiring touching most of our code base
this would have required much more work...

Both changes are theoretically big major breaking changes. For
application code I expect the actual breakage to be minimal, see the
required changes in `diesel_tests` and `diesel_cli` for examples. For
highly generic code I would expect quite a few required changes.

Additionally there are a few small drive by fixes.

Fixes diesel-rs#104
Fixes diesel-rs#2274
Fixes diesel-rs#2161
weiznich added a commit to GiGainfosystems/diesel that referenced this issue Jul 17, 2020
(Sorry for the really large diff but this touches nearly all parts of
diesel)

This commit does in two things:
* Refactor our handling of nullable values. Instead of having a marker
trait for non nullable sql types we now indicate if a sql type is
nullable by using a associated type on a new fundamental trait named
SqlType. This allows us to reason if an type is nullable or not in a
much precise way without running in conflicting implementation
issues. This allows us to address diesel-rs#104 in a much more fundamental
way. (The correct way as mentioned there by sgrif).
* Refactor our handling of typed and untyped sql fragments. Instead of
having two separate code paths for `Queryable` (sql types known) and
`QueryableByName` (sql types not known) we now have only one code path
and indicate if a query is typed or untyped as part of the expression
sql type. This is required to address diesel-rs#2150. As part of this change we
unify `Queryable`, `QueryableByName` and `FromSqlRow` into only
`FromSqlRow`. Additionally we separate the static size component of
`FromSqlRow` to allow dynamically sized rows there (but only at the
last position for tuple impls.)

I should probably have implement those changes in different commits
but as both changes basically requiring touching most of our code base
this would have required much more work...

Both changes are theoretically big major breaking changes. For
application code I expect the actual breakage to be minimal, see the
required changes in `diesel_tests` and `diesel_cli` for examples. For
highly generic code I would expect quite a few required changes.

Additionally there are a few small drive by fixes.

Fixes diesel-rs#104
Fixes diesel-rs#2274
Fixes diesel-rs#2161
weiznich added a commit to GiGainfosystems/diesel that referenced this issue Jul 18, 2020
(Sorry for the really large diff but this touches nearly all parts of
diesel)

This commit does in two things:
* Refactor our handling of nullable values. Instead of having a marker
trait for non nullable sql types we now indicate if a sql type is
nullable by using a associated type on a new fundamental trait named
SqlType. This allows us to reason if an type is nullable or not in a
much precise way without running in conflicting implementation
issues. This allows us to address diesel-rs#104 in a much more fundamental
way. (The correct way as mentioned there by sgrif).
* Refactor our handling of typed and untyped sql fragments. Instead of
having two separate code paths for `Queryable` (sql types known) and
`QueryableByName` (sql types not known) we now have only one code path
and indicate if a query is typed or untyped as part of the expression
sql type. This is required to address diesel-rs#2150. As part of this change we
unify `Queryable`, `QueryableByName` and `FromSqlRow` into only
`FromSqlRow`. Additionally we separate the static size component of
`FromSqlRow` to allow dynamically sized rows there (but only at the
last position for tuple impls.)

I should probably have implement those changes in different commits
but as both changes basically requiring touching most of our code base
this would have required much more work...

Both changes are theoretically big major breaking changes. For
application code I expect the actual breakage to be minimal, see the
required changes in `diesel_tests` and `diesel_cli` for examples. For
highly generic code I would expect quite a few required changes.

Additionally there are a few small drive by fixes.

Fixes diesel-rs#104
Fixes diesel-rs#2274
Fixes diesel-rs#2161
weiznich added a commit to GiGainfosystems/diesel that referenced this issue Jul 20, 2020
(Sorry for the really large diff but this touches nearly all parts of
diesel)

This commit does in two things:
* Refactor our handling of nullable values. Instead of having a marker
trait for non nullable sql types we now indicate if a sql type is
nullable by using a associated type on a new fundamental trait named
SqlType. This allows us to reason if an type is nullable or not in a
much precise way without running in conflicting implementation
issues. This allows us to address diesel-rs#104 in a much more fundamental
way. (The correct way as mentioned there by sgrif).
* Refactor our handling of typed and untyped sql fragments. Instead of
having two separate code paths for `Queryable` (sql types known) and
`QueryableByName` (sql types not known) we now have only one code path
and indicate if a query is typed or untyped as part of the expression
sql type. This is required to address diesel-rs#2150. As part of this change we
unify `Queryable`, `QueryableByName` and `FromSqlRow` into only
`FromSqlRow`. Additionally we separate the static size component of
`FromSqlRow` to allow dynamically sized rows there (but only at the
last position for tuple impls.)

I should probably have implement those changes in different commits
but as both changes basically requiring touching most of our code base
this would have required much more work...

Both changes are theoretically big major breaking changes. For
application code I expect the actual breakage to be minimal, see the
required changes in `diesel_tests` and `diesel_cli` for examples. For
highly generic code I would expect quite a few required changes.

Additionally there are a few small drive by fixes.

Fixes diesel-rs#104
Fixes diesel-rs#2274
Fixes diesel-rs#2161
weiznich added a commit to GiGainfosystems/diesel that referenced this issue Jul 21, 2020
(Sorry for the really large diff but this touches nearly all parts of
diesel)

This commit does in two things:
* Refactor our handling of nullable values. Instead of having a marker
trait for non nullable sql types we now indicate if a sql type is
nullable by using a associated type on a new fundamental trait named
SqlType. This allows us to reason if an type is nullable or not in a
much precise way without running in conflicting implementation
issues. This allows us to address diesel-rs#104 in a much more fundamental
way. (The correct way as mentioned there by sgrif).
* Refactor our handling of typed and untyped sql fragments. Instead of
having two separate code paths for `Queryable` (sql types known) and
`QueryableByName` (sql types not known) we now have only one code path
and indicate if a query is typed or untyped as part of the expression
sql type. This is required to address diesel-rs#2150. As part of this change we
unify `Queryable`, `QueryableByName` and `FromSqlRow` into only
`FromSqlRow`. Additionally we separate the static size component of
`FromSqlRow` to allow dynamically sized rows there (but only at the
last position for tuple impls.)

I should probably have implement those changes in different commits
but as both changes basically requiring touching most of our code base
this would have required much more work...

Both changes are theoretically big major breaking changes. For
application code I expect the actual breakage to be minimal, see the
required changes in `diesel_tests` and `diesel_cli` for examples. For
highly generic code I would expect quite a few required changes.

Additionally there are a few small drive by fixes.

Fixes diesel-rs#104
Fixes diesel-rs#2274
Fixes diesel-rs#2161
weiznich added a commit to GiGainfosystems/diesel that referenced this issue Jul 21, 2020
(Sorry for the really large diff but this touches nearly all parts of
diesel)

This commit does in two things:
* Refactor our handling of nullable values. Instead of having a marker
trait for non nullable sql types we now indicate if a sql type is
nullable by using a associated type on a new fundamental trait named
SqlType. This allows us to reason if an type is nullable or not in a
much precise way without running in conflicting implementation
issues. This allows us to address diesel-rs#104 in a much more fundamental
way. (The correct way as mentioned there by sgrif).
* Refactor our handling of typed and untyped sql fragments. Instead of
having two separate code paths for `Queryable` (sql types known) and
`QueryableByName` (sql types not known) we now have only one code path
and indicate if a query is typed or untyped as part of the expression
sql type. This is required to address diesel-rs#2150. As part of this change we
unify `Queryable`, `QueryableByName` and `FromSqlRow` into only
`FromSqlRow`. Additionally we separate the static size component of
`FromSqlRow` to allow dynamically sized rows there (but only at the
last position for tuple impls.)

I should probably have implement those changes in different commits
but as both changes basically requiring touching most of our code base
this would have required much more work...

Both changes are theoretically big major breaking changes. For
application code I expect the actual breakage to be minimal, see the
required changes in `diesel_tests` and `diesel_cli` for examples. For
highly generic code I would expect quite a few required changes.

Additionally there are a few small drive by fixes.

Fixes diesel-rs#104
Fixes diesel-rs#2274
Fixes diesel-rs#2161
weiznich added a commit to GiGainfosystems/diesel that referenced this issue Jul 21, 2020
(Sorry for the really large diff but this touches nearly all parts of
diesel)

This commit does in two things:
* Refactor our handling of nullable values. Instead of having a marker
trait for non nullable sql types we now indicate if a sql type is
nullable by using a associated type on a new fundamental trait named
SqlType. This allows us to reason if an type is nullable or not in a
much precise way without running in conflicting implementation
issues. This allows us to address diesel-rs#104 in a much more fundamental
way. (The correct way as mentioned there by sgrif).
* Refactor our handling of typed and untyped sql fragments. Instead of
having two separate code paths for `Queryable` (sql types known) and
`QueryableByName` (sql types not known) we now have only one code path
and indicate if a query is typed or untyped as part of the expression
sql type. This is required to address diesel-rs#2150. As part of this change we
unify `Queryable`, `QueryableByName` and `FromSqlRow` into only
`FromSqlRow`. Additionally we separate the static size component of
`FromSqlRow` to allow dynamically sized rows there (but only at the
last position for tuple impls.)

I should probably have implement those changes in different commits
but as both changes basically requiring touching most of our code base
this would have required much more work...

Both changes are theoretically big major breaking changes. For
application code I expect the actual breakage to be minimal, see the
required changes in `diesel_tests` and `diesel_cli` for examples. For
highly generic code I would expect quite a few required changes.

Additionally there are a few small drive by fixes.

Fixes diesel-rs#104
Fixes diesel-rs#2274
Fixes diesel-rs#2161
weiznich added a commit to GiGainfosystems/diesel that referenced this issue Jul 31, 2020
(Sorry for the really large diff but this touches nearly all parts of
diesel)

This commit does in two things:
* Refactor our handling of nullable values. Instead of having a marker
trait for non nullable sql types we now indicate if a sql type is
nullable by using a associated type on a new fundamental trait named
SqlType. This allows us to reason if an type is nullable or not in a
much precise way without running in conflicting implementation
issues. This allows us to address diesel-rs#104 in a much more fundamental
way. (The correct way as mentioned there by sgrif).
* Refactor our handling of typed and untyped sql fragments. Instead of
having two separate code paths for `Queryable` (sql types known) and
`QueryableByName` (sql types not known) we now have only one code path
and indicate if a query is typed or untyped as part of the expression
sql type. This is required to address diesel-rs#2150. `Queryable` and
`QueryableByName` now simple . Additionally we separate the static size component of
`FromSqlRow` to allow dynamically sized rows there (but only at the
last position for tuple impls.)

I should probably have implement those changes in different commits
but as both changes basically requiring touching most of our code base
this would have required much more work...

Both changes are theoretically big major breaking changes. For
application code I expect the actual breakage to be minimal, see the
required changes in `diesel_tests` and `diesel_cli` for examples. For
highly generic code I would expect quite a few required changes.

Additionally there are a few small drive by fixes.

Fixes diesel-rs#104
Fixes diesel-rs#2274
Fixes diesel-rs#2161
weiznich added a commit to GiGainfosystems/diesel that referenced this issue Jul 31, 2020
(Sorry for the really large diff but this touches nearly all parts of
diesel)

This commit does in two things:
* Refactor our handling of nullable values. Instead of having a marker
trait for non nullable sql types we now indicate if a sql type is
nullable by using a associated type on a new fundamental trait named
SqlType. This allows us to reason if an type is nullable or not in a
much precise way without running in conflicting implementation
issues. This allows us to address diesel-rs#104 in a much more fundamental
way. (The correct way as mentioned there by sgrif).
* Refactor our handling of typed and untyped sql fragments. Instead of
having two separate code paths for `Queryable` (sql types known) and
`QueryableByName` (sql types not known) we now have only one code path
and indicate if a query is typed or untyped as part of the expression
sql type. This is required to address diesel-rs#2150. `Queryable` and
`QueryableByName` now simple . Additionally we separate the static size component of
`FromSqlRow` to allow dynamically sized rows there (but only at the
last position for tuple impls.)

I should probably have implement those changes in different commits
but as both changes basically requiring touching most of our code base
this would have required much more work...

Both changes are theoretically big major breaking changes. For
application code I expect the actual breakage to be minimal, see the
required changes in `diesel_tests` and `diesel_cli` for examples. For
highly generic code I would expect quite a few required changes.

Additionally there are a few small drive by fixes.

Fixes diesel-rs#104
Fixes diesel-rs#2274
Fixes diesel-rs#2161
weiznich added a commit to GiGainfosystems/diesel that referenced this issue Jul 31, 2020
(Sorry for the really large diff but this touches nearly all parts of
diesel)

This commit does in two things:
* Refactor our handling of nullable values. Instead of having a marker
trait for non nullable sql types we now indicate if a sql type is
nullable by using a associated type on a new fundamental trait named
SqlType. This allows us to reason if an type is nullable or not in a
much precise way without running in conflicting implementation
issues. This allows us to address diesel-rs#104 in a much more fundamental
way. (The correct way as mentioned there by sgrif).
* Refactor our handling of typed and untyped sql fragments. Instead of
having two separate code paths for `Queryable` (sql types known) and
`QueryableByName` (sql types not known) we now have only one code path
and indicate if a query is typed or untyped as part of the expression
sql type. This is required to address diesel-rs#2150. `Queryable` and
`QueryableByName` now simple . Additionally we separate the static size component of
`FromSqlRow` to allow dynamically sized rows there (but only at the
last position for tuple impls.)

I should probably have implement those changes in different commits
but as both changes basically requiring touching most of our code base
this would have required much more work...

Both changes are theoretically big major breaking changes. For
application code I expect the actual breakage to be minimal, see the
required changes in `diesel_tests` and `diesel_cli` for examples. For
highly generic code I would expect quite a few required changes.

Additionally there are a few small drive by fixes.

Fixes diesel-rs#104
Fixes diesel-rs#2274
Fixes diesel-rs#2161
weiznich added a commit to GiGainfosystems/diesel that referenced this issue Jul 31, 2020
(Sorry for the really large diff but this touches nearly all parts of
diesel)

This commit does in two things:
* Refactor our handling of nullable values. Instead of having a marker
trait for non nullable sql types we now indicate if a sql type is
nullable by using a associated type on a new fundamental trait named
SqlType. This allows us to reason if an type is nullable or not in a
much precise way without running in conflicting implementation
issues. This allows us to address diesel-rs#104 in a much more fundamental
way. (The correct way as mentioned there by sgrif).
* Refactor our handling of typed and untyped sql fragments. Instead of
having two separate code paths for `Queryable` (sql types known) and
`QueryableByName` (sql types not known) we now have only one code path
and indicate if a query is typed or untyped as part of the expression
sql type. This is required to address diesel-rs#2150. `Queryable` and
`QueryableByName` now simple . Additionally we separate the static size component of
`FromSqlRow` to allow dynamically sized rows there (but only at the
last position for tuple impls.)

I should probably have implement those changes in different commits
but as both changes basically requiring touching most of our code base
this would have required much more work...

Both changes are theoretically big major breaking changes. For
application code I expect the actual breakage to be minimal, see the
required changes in `diesel_tests` and `diesel_cli` for examples. For
highly generic code I would expect quite a few required changes.

Additionally there are a few small drive by fixes.

Fixes diesel-rs#104
Fixes diesel-rs#2274
Fixes diesel-rs#2161
weiznich added a commit to GiGainfosystems/diesel that referenced this issue Jul 31, 2020
(Sorry for the really large diff but this touches nearly all parts of
diesel)

This commit does in two things:
* Refactor our handling of nullable values. Instead of having a marker
trait for non nullable sql types we now indicate if a sql type is
nullable by using a associated type on a new fundamental trait named
SqlType. This allows us to reason if an type is nullable or not in a
much precise way without running in conflicting implementation
issues. This allows us to address diesel-rs#104 in a much more fundamental
way. (The correct way as mentioned there by sgrif).
* Refactor our handling of typed and untyped sql fragments. Instead of
having two separate code paths for `Queryable` (sql types known) and
`QueryableByName` (sql types not known) we now have only one code path
and indicate if a query is typed or untyped as part of the expression
sql type. This is required to address diesel-rs#2150. `Queryable` and
`QueryableByName` now simple . Additionally we separate the static size component of
`FromSqlRow` to allow dynamically sized rows there (but only at the
last position for tuple impls.)

I should probably have implement those changes in different commits
but as both changes basically requiring touching most of our code base
this would have required much more work...

Both changes are theoretically big major breaking changes. For
application code I expect the actual breakage to be minimal, see the
required changes in `diesel_tests` and `diesel_cli` for examples. For
highly generic code I would expect quite a few required changes.

Additionally there are a few small drive by fixes.

Fixes diesel-rs#104
Fixes diesel-rs#2274
Fixes diesel-rs#2161
weiznich added a commit to GiGainfosystems/diesel that referenced this issue Jul 31, 2020
(Sorry for the really large diff but this touches nearly all parts of
diesel)

This commit does in two things:
* Refactor our handling of nullable values. Instead of having a marker
trait for non nullable sql types we now indicate if a sql type is
nullable by using a associated type on a new fundamental trait named
SqlType. This allows us to reason if an type is nullable or not in a
much precise way without running in conflicting implementation
issues. This allows us to address diesel-rs#104 in a much more fundamental
way. (The correct way as mentioned there by sgrif).
* Refactor our handling of typed and untyped sql fragments. Instead of
having two separate code paths for `Queryable` (sql types known) and
`QueryableByName` (sql types not known) we now have only one code path
and indicate if a query is typed or untyped as part of the expression
sql type. This is required to address diesel-rs#2150. `Queryable` and
`QueryableByName` now simple . Additionally we separate the static size component of
`FromSqlRow` to allow dynamically sized rows there (but only at the
last position for tuple impls.)

I should probably have implement those changes in different commits
but as both changes basically requiring touching most of our code base
this would have required much more work...

Both changes are theoretically big major breaking changes. For
application code I expect the actual breakage to be minimal, see the
required changes in `diesel_tests` and `diesel_cli` for examples. For
highly generic code I would expect quite a few required changes.

Additionally there are a few small drive by fixes.

Fixes diesel-rs#104
Fixes diesel-rs#2274
Fixes diesel-rs#2161
weiznich added a commit to GiGainfosystems/diesel that referenced this issue Jul 31, 2020
(Sorry for the really large diff but this touches nearly all parts of
diesel)

This commit does in two things:
* Refactor our handling of nullable values. Instead of having a marker
trait for non nullable sql types we now indicate if a sql type is
nullable by using a associated type on a new fundamental trait named
SqlType. This allows us to reason if an type is nullable or not in a
much precise way without running in conflicting implementation
issues. This allows us to address diesel-rs#104 in a much more fundamental
way. (The correct way as mentioned there by sgrif).
* Refactor our handling of typed and untyped sql fragments. Instead of
having two separate code paths for `Queryable` (sql types known) and
`QueryableByName` (sql types not known) we now have only one code path
and indicate if a query is typed or untyped as part of the expression
sql type. This is required to address diesel-rs#2150. `Queryable` and
`QueryableByName` now simple . Additionally we separate the static size component of
`FromSqlRow` to allow dynamically sized rows there (but only at the
last position for tuple impls.)

I should probably have implement those changes in different commits
but as both changes basically requiring touching most of our code base
this would have required much more work...

Both changes are theoretically big major breaking changes. For
application code I expect the actual breakage to be minimal, see the
required changes in `diesel_tests` and `diesel_cli` for examples. For
highly generic code I would expect quite a few required changes.

Additionally there are a few small drive by fixes.

Fixes diesel-rs#104
Fixes diesel-rs#2274
Fixes diesel-rs#2161
weiznich added a commit to GiGainfosystems/diesel that referenced this issue Jul 31, 2020
(Sorry for the really large diff but this touches nearly all parts of
diesel)

This commit does in two things:
* Refactor our handling of nullable values. Instead of having a marker
trait for non nullable sql types we now indicate if a sql type is
nullable by using a associated type on a new fundamental trait named
SqlType. This allows us to reason if an type is nullable or not in a
much precise way without running in conflicting implementation
issues. This allows us to address diesel-rs#104 in a much more fundamental
way. (The correct way as mentioned there by sgrif).
* Refactor our handling of typed and untyped sql fragments. Instead of
having two separate code paths for `Queryable` (sql types known) and
`QueryableByName` (sql types not known) we now have only one code path
and indicate if a query is typed or untyped as part of the expression
sql type. This is required to address diesel-rs#2150. `Queryable` and
`QueryableByName` now simple . Additionally we separate the static size component of
`FromSqlRow` to allow dynamically sized rows there (but only at the
last position for tuple impls.)

I should probably have implement those changes in different commits
but as both changes basically requiring touching most of our code base
this would have required much more work...

Both changes are theoretically big major breaking changes. For
application code I expect the actual breakage to be minimal, see the
required changes in `diesel_tests` and `diesel_cli` for examples. For
highly generic code I would expect quite a few required changes.

Additionally there are a few small drive by fixes.

Fixes diesel-rs#104
Fixes diesel-rs#2274
Fixes diesel-rs#2161
weiznich added a commit to GiGainfosystems/diesel that referenced this issue Aug 1, 2020
(Sorry for the really large diff but this touches nearly all parts of
diesel)

This commit does in two things:
* Refactor our handling of nullable values. Instead of having a marker
trait for non nullable sql types we now indicate if a sql type is
nullable by using a associated type on a new fundamental trait named
SqlType. This allows us to reason if an type is nullable or not in a
much precise way without running in conflicting implementation
issues. This allows us to address diesel-rs#104 in a much more fundamental
way. (The correct way as mentioned there by sgrif).
* Refactor our handling of typed and untyped sql fragments. Instead of
having two separate code paths for `Queryable` (sql types known) and
`QueryableByName` (sql types not known) we now have only one code path
and indicate if a query is typed or untyped as part of the expression
sql type. This is required to address diesel-rs#2150. `Queryable` and
`QueryableByName` now simple . Additionally we separate the static size component of
`FromSqlRow` to allow dynamically sized rows there (but only at the
last position for tuple impls.)

I should probably have implement those changes in different commits
but as both changes basically requiring touching most of our code base
this would have required much more work...

Both changes are theoretically big major breaking changes. For
application code I expect the actual breakage to be minimal, see the
required changes in `diesel_tests` and `diesel_cli` for examples. For
highly generic code I would expect quite a few required changes.

Additionally there are a few small drive by fixes.

Fixes diesel-rs#104
Fixes diesel-rs#2274
Fixes diesel-rs#2161
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants