Skip to content

Date::to_s doesn't respect connection language #72

@henrymazza

Description

@henrymazza

If the machine isn't configured in english the connection will be stablished in that other language which breaks all .where(:date => Date.today) and similar commands because SQLServer starts to look for locale aware date format.

In my case

Devolucao.connection.user_options[:language]

returns "us_english" in my development machine and "Português" on my customer's server. On my machine '2010-12-24' is acceptable, on theirs it causes a out-of-range date conversion error. '24-12-2010' middle endian date otherwise is acceptable.

Easy way out is force the connection to use english, that should be done as soon the connection happens:

SET language 'us_english'

The better way would be to overload the :db conversion of Date::to_s to a locale sensible SQLServer compatible code.

PS: Error obtained

TinyTds::Error: The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions