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

Support `diesel_manage_updated_at` on SQLite #1871

Closed
wants to merge 1 commit into from

Conversation

@sgrif
Copy link
Member

@sgrif sgrif commented Oct 3, 2018

There's a little bit of funkiness required to make this work. The first
piece is that we need to modify the function registration to provide
access to the connection for our internal functions. This isn't
strictly necessary, we could transmute the &self to be &'static self, since the function will never be called after self is dropped.
That felt like it would add some unneccessary unsafety though.

The second bit of funkiness is that we have to have some return type,
so we can't just return (). I think I want to fix this in the future
by providing a Null SQL type, which provides ToSql and FromSql
impls only for (). This requires adding a variant to SqliteType and
MysqlType though, so it will have to be done in 2.0.

The function itself is subtly different from the PostgreSQL version,
since it runs even if no values were actually changed (we can't do
something like NEW IS DISTINCT FROM OLD here). This also cannot be run
on tables without ROWIDs. I think we should probably declare this as a
SQL function in code somewhere for documentation purposes, but I want to
wait until our docs are building again to follow up with that.

There's a little bit of funkiness required to make this work. The first
piece is that we need to modify the function registration to provide
access to the connection for our internal functions. This isn't
*strictly* necessary, we could `transmute` the `&self` to be `&'static
self`, since the function will never be called after `self` is dropped.
That felt like it would add some unneccessary unsafety though.

The second bit of funkiness is that we have to have *some* return type,
so we can't just return `()`. I think I want to fix this in the future
by providing a `Null` SQL type, which provides `ToSql` and `FromSql`
impls only for `()`. This requires adding a variant to `SqliteType` and
`MysqlType` though, so it will have to be done in 2.0.

The function itself is subtly different from the PostgreSQL version,
since it runs even if no values were actually changed (we can't do
something like `NEW IS DISTINCT FROM OLD` here). This also cannot be run
on tables without ROWIDs. I think we should probably declare this as a
SQL function in code somewhere for documentation purposes, but I want to
wait until our docs are building again to follow up with that.
@sgrif sgrif requested a review from diesel-rs/reviewers Oct 3, 2018
@weiznich weiznich added this to the 1.4 milestone Jan 9, 2019
@weiznich
Copy link
Member

@weiznich weiznich commented Jan 9, 2019

@sgrif Needs rebase.

weiznich added a commit that referenced this pull request Jan 14, 2019
Rebase of #1871: Support `diesel_manage_updated_at` on SQLite
@weiznich
Copy link
Member

@weiznich weiznich commented Jan 14, 2019

Closed by #1955

@weiznich weiznich closed this Jan 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.