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

Format the time string according to the precision of the time column #18914

Merged
merged 3 commits into from Feb 20, 2015

Conversation

kamipo
Copy link
Member

@kamipo kamipo commented Feb 12, 2015

It is also necessary to format a time column like a datetime column.

@@ -733,7 +733,7 @@ def register_integer_type(mapping, key, options) # :nodoc:
end

def extract_precision(sql_type)
if /datetime/ === sql_type
if /^(?:date)?time/ === sql_type
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was the missing ^ anchor intentional before?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the missing ^ anchor not intentional.

If you prefer to shortest pattern, it is possible to match /time/. It is only datetime, timestamp and time to match this in MySQL. These types can have a precision.

http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html

@kamipo kamipo force-pushed the format_time_according_to_precision branch 4 times, most recently from 20653ef to 30f9175 Compare February 17, 2015 08:59
@@ -87,7 +87,7 @@ platforms :ruby do
group :db do
gem 'pg', '>= 0.18.0'
gem 'mysql', '>= 2.9.0'
gem 'mysql2', '>= 0.3.13'
gem 'mysql2', '>= 0.3.18'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.3.18 includes fix msec for time field is not passed. brianmario/mysql2#579

@kamipo kamipo force-pushed the format_time_according_to_precision branch 4 times, most recently from e628c27 to 2803623 Compare February 19, 2015 12:03
@kamipo kamipo force-pushed the format_time_according_to_precision branch from 2803623 to cddc298 Compare February 20, 2015 01:26
rafaelfranca added a commit that referenced this pull request Feb 20, 2015
Format the time string according to the precision of the time column
@rafaelfranca rafaelfranca merged commit bb9d20c into rails:master Feb 20, 2015
@kamipo kamipo deleted the format_time_according_to_precision branch February 20, 2015 20:23
kamipo added a commit to kamipo/rails that referenced this pull request May 3, 2015
kamipo added a commit to kamipo/rails that referenced this pull request May 3, 2015
yahonda added a commit to yahonda/oracle-enhanced that referenced this pull request Apr 18, 2016
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 this pull request may close these issues.

None yet

3 participants