SubSonic Forums
All Your Database Are Belong To Us

Possible issue with SqlQuery system (AndBetween Dates)

Latest post 07-28-2008 12:36 PM by penyaskito. 5 replies.
  • 07-24-2008 10:04 AM

    Possible issue with SqlQuery system (AndBetween Dates)

    Hi,

    I'm having problems with SqlQuery when I add a Between Constraint to a Select.

    The exception says:

    Exception Details: System.Data.SqlClient?.SqlException?: The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

    Source Error:

    Line 203:        public void Load(IDataReader dataReader)
    Line 204: {
    Line 205: while (dataReader.Read())
    Line 206: {
    Line 207: ItemType item = new ItemType();

    Source File: D:\My Documents\Work\Gesmed\SubSonic\SubSonic\ActiveRecord\AbstractList.cs Line: 205



    As you will know, it is a conversion problem between data formats. Profiling SQL Server I found that the query was sent with varchar params instead of datetimes.

    If I run queries with the older Queries system, I have no problem

    This works:

    query = new SubSonic.Query(Calibracion.Schema).
    WHERE("idMagnitud", (int)IdMagnitud).
    BETWEEN_AND("Fecha", datetime0, datetime1);


    This query only works depending on the SQL Server locale:


    SubSonic.SqlQuery query = new SubSonic.Select("COUNT(DISTINCT Equipo.id)").From(Equipo.Schema).
    InnerJoin(EquipoMagnitud.Schema.TableName,EquipoMagnitud.IdEquipoColumn.ColumnName,Equipo.Schema.TableName, Equipo.IdColumn.ColumnName).
    InnerJoin(Calibracion.Schema.TableName, Calibracion.IdMagnitudColumn.ColumnName,EquipoMagnitud.Schema.TableName, EquipoMagnitud.IdMagnitudColumn.ColumnName)
    .
    Where(Calibracion.ProximaColumn.ColumnName).
    IsBetweenAnd(DateTime.Today, DateTime.Today.AddDays(dias));


    Thanks for any kind of help.

    Christian Lopez Espinola http://penyaskitodice.wordpress.com
  • 07-24-2008 12:23 PM In reply to

    Re: Possible issue with SqlQuery system (AndBetween Dates)

    Definitively is a bug, and I have a patch that solves the problem.

    I'm running the unit tests, ASAP and they run and pass, I'll attach a patch.

     

    Christian Lopez Espinola http://penyaskitodice.wordpress.com
  • 07-24-2008 1:53 PM In reply to

    Re: Possible issue with SqlQuery system (AndBetween Dates)

    Because I don't know what is the right issue tracker, I attached it on both.

    Christian Lopez Espinola http://penyaskitodice.wordpress.com
  • 07-24-2008 1:57 PM In reply to

    Re: Possible issue with SqlQuery system (AndBetween Dates)

     Awesome - thank you. The patch looks great!

    Find a bug? Create a Work Item for a fast response.. Want to help? Create a patch for us!

  • 07-28-2008 12:27 PM In reply to

    Re: Possible issue with SqlQuery system (AndBetween Dates)

    Fixed in Revision 479

    Found a bug? Help us fix it by submitting a Work Item!

  • 07-28-2008 12:36 PM In reply to

    Re: Possible issue with SqlQuery system (AndBetween Dates)

    Kudos Eric

    Christian Lopez Espinola http://penyaskitodice.wordpress.com
Page 1 of 1 (6 items) | RSS