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

Should keep quoting behaivor of a time column value in sqlite3 adapter #24549

Merged
merged 1 commit into from
Apr 15, 2016

Conversation

kamipo
Copy link
Member

@kamipo kamipo commented Apr 14, 2016

Follow up to #24542.

In MySQL and PostgreSQL, a time column value is saved as ignored the
date part of it. But in SQLite3, a time column value is saved as a string.

We should keep previous quoting behavior in sqlite3 adapter.

sqlite> CREATE TABLE "foos" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "start" time(0), "finish" time(4));
sqlite> INSERT INTO "foos" ("start", "finish") VALUES ('2000-01-01 12:30:00', '2000-01-01 12:30:00.999900');
sqlite> SELECT "foos".* FROM "foos";
1|2000-01-01 12:30:00|2000-01-01 12:30:00.999900
sqlite> SELECT  "foos".* FROM "foos" WHERE "foos"."start" = '2000-01-01 12:30:00' LIMIT 1;
1|2000-01-01 12:30:00|2000-01-01 12:30:00.999900
sqlite> SELECT  "foos".* FROM "foos" WHERE "foos"."start" = '12:30:00' LIMIT 1;
sqlite>

r? @jeremy

@jeremy
Copy link
Member

jeremy commented Apr 14, 2016

Looks good. Test coverage?

Follow up to rails#24542.

In MySQL and PostgreSQL, a time column value is saved as ignored the
date part of it. But in SQLite3, a time column value is saved as a string.

We should keep previous quoting behavior in sqlite3 adapter.

```
sqlite> CREATE TABLE "foos" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "start" time(0), "finish" time(4));
sqlite> INSERT INTO "foos" ("start", "finish") VALUES ('2000-01-01 12:30:00', '2000-01-01 12:30:00.999900');
sqlite> SELECT "foos".* FROM "foos";
1|2000-01-01 12:30:00|2000-01-01 12:30:00.999900
sqlite> SELECT  "foos".* FROM "foos" WHERE "foos"."start" = '2000-01-01 12:30:00' LIMIT 1;
1|2000-01-01 12:30:00|2000-01-01 12:30:00.999900
sqlite> SELECT  "foos".* FROM "foos" WHERE "foos"."start" = '12:30:00' LIMIT 1;
sqlite>
```
@kamipo
Copy link
Member Author

kamipo commented Apr 14, 2016

I added a test case!

@vipulnsward
Copy link
Member

I forgot, in #24542 we fixed/added support for new behaviour. Should that have a changelog?

@jeremy jeremy merged commit a2de667 into rails:master Apr 15, 2016
@jeremy
Copy link
Member

jeremy commented Apr 15, 2016

@vipulnsward Seems like a good idea. The quoting behavior should be completely transparent to Rails users. But it does make TIME columns work on MariaDB!

@kamipo kamipo deleted the fix_quoted_time branch April 15, 2016 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants