something strange with sqlite ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

something strange with sqlite ?

Joe Guerra
I have an active record query (for my categories) that check for the date ( .where( 'enddate > ?', todaydate )).

Today's date get's wrapped in quotes, and it fails to produce any records, but it's perfectly fine in postgres.


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/394a0f57-7d77-4d73-82ce-fd9730bc90b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: something strange with sqlite ?

Rob Zolkos-2
I think you will need to wrap todaydate in strftime for sqlite.   Away from computer to check but google ‘date arithmetic sqlite’

On Tue, 18 Sep 2018 at 6:20 am, Joe Guerra <[hidden email]> wrote:
I have an active record query (for my categories) that check for the date ( .where( 'enddate > ?', todaydate )).

Today's date get's wrapped in quotes, and it fails to produce any records, but it's perfectly fine in postgres.


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/394a0f57-7d77-4d73-82ce-fd9730bc90b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAJ6MPzJR9hQOO-ECQ8rd2DrC0JOUmX1JzymD%3Df%3DgU0TkJA94qg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: something strange with sqlite ?

Joe Guerra
Thanks, I'll try that.

Hopefully it works for postgres and sqlite.

On Mon, Sep 17, 2018, 5:18 PM Rob Zolkos, <[hidden email]> wrote:
I think you will need to wrap todaydate in strftime for sqlite.   Away from computer to check but google ‘date arithmetic sqlite’

On Tue, 18 Sep 2018 at 6:20 am, Joe Guerra <[hidden email]> wrote:
I have an active record query (for my categories) that check for the date ( .where( 'enddate > ?', todaydate )).

Today's date get's wrapped in quotes, and it fails to produce any records, but it's perfectly fine in postgres.


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/394a0f57-7d77-4d73-82ce-fd9730bc90b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAJ6MPzJR9hQOO-ECQ8rd2DrC0JOUmX1JzymD%3Df%3DgU0TkJA94qg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAOFgAMmVVh5jtGQU3jwHDhb1f74OJp6m88FYaV5S0V%2BJ%2BKRRkQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: something strange with sqlite ?

Rob Zolkos-2
doubtful.  They are very different.  Any reason you can't stick with one of them?

On Tue, Sep 18, 2018 at 8:24 AM Joe Guerra <[hidden email]> wrote:
Thanks, I'll try that.

Hopefully it works for postgres and sqlite.

On Mon, Sep 17, 2018, 5:18 PM Rob Zolkos, <[hidden email]> wrote:
I think you will need to wrap todaydate in strftime for sqlite.   Away from computer to check but google ‘date arithmetic sqlite’

On Tue, 18 Sep 2018 at 6:20 am, Joe Guerra <[hidden email]> wrote:
I have an active record query (for my categories) that check for the date ( .where( 'enddate > ?', todaydate )).

Today's date get's wrapped in quotes, and it fails to produce any records, but it's perfectly fine in postgres.


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/394a0f57-7d77-4d73-82ce-fd9730bc90b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAJ6MPzJR9hQOO-ECQ8rd2DrC0JOUmX1JzymD%3Df%3DgU0TkJA94qg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAOFgAMmVVh5jtGQU3jwHDhb1f74OJp6m88FYaV5S0V%2BJ%2BKRRkQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAJ6MPzLzJBpfyTems%3DsJL75GLY04FVym5H9rbgVYejG7q7__Kg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: something strange with sqlite ?

Hassan Schroeder-2
In reply to this post by Joe Guerra
On Mon, Sep 17, 2018 at 1:20 PM, Joe Guerra <[hidden email]> wrote:
> I have an active record query (for my categories) that check for the date (
> .where( 'enddate > ?', todaydate )).
>
> Today's date get's wrapped in quotes, and it fails to produce any records,
> but it's perfectly fine in postgres.

What exactly is "todaydate"? What's the column definition of "enddate"?

And are you sure you have identical records in both DBs you're testing
this with?

--
Hassan Schroeder ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yBYmgErVK_RYzxZPGEkJ8kUkdcAaC42emNRNJTb0u5BKw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: something strange with sqlite ?

Joe Guerra
Hi, I defined time like this --->

  require 'time'

    todaydate = Time.new

    todaydate = todaydate.year.to_s + "-" + todaydate.month.to_s + "-" + todaydate.day.to_s

and the column for enddate is a date type.   It had worked previously, I just updated the dates in a populate rake file and stopped working (on the development env (sqlite)).

Thanks,
Joe

On Monday, September 17, 2018 at 7:34:00 PM UTC-4, Hassan Schroeder wrote:
On Mon, Sep 17, 2018 at 1:20 PM, Joe Guerra <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="gw0S4OQ4CgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">JGu...@...> wrote:
> I have an active record query (for my categories) that check for the date (
> .where( 'enddate > ?', todaydate )).
>
> Today's date get's wrapped in quotes, and it fails to produce any records,
> but it's perfectly fine in postgres.

What exactly is "todaydate"? What's the column definition of "enddate"?

And are you sure you have identical records in both DBs you're testing
this with?

--
Hassan Schroeder ------------------------ <a href="javascript:" target="_blank" gdf-obfuscated-mailto="gw0S4OQ4CgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">hassan.s...@...
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/d273f500-5d2c-47fe-beeb-57ad4d280560%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: something strange with sqlite ?

Hassan Schroeder-2
On Tue, Sep 18, 2018 at 5:59 AM, Joe Guerra <[hidden email]> wrote:

>     todaydate = Time.new
>
>     todaydate = todaydate.year.to_s + "-" + todaydate.month.to_s + "-" +
> todaydate.day.to_s
>
> and the column for enddate is a date type.

Aside from the potential problem of redefining the same variable,
I'd avoid trying to compare a DB `date` with a String, but in this case --

Sqlite3 doesn't have a `date` type so you might want to spend a few
minutes here: https://www.sqlite.org/datatype3.html

 HTH!
--
Hassan Schroeder ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yANQfJPrbONT-QfdGMEG_9bfkvoC9Yie4PkVuceo9cpcA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.