Re: Feature Request: UNIX_TIMESTAMP

2016-10-12 Thread Jeremy Evans
On Wednesday, October 12, 2016 at 10:42:38 AM UTC-7, Alexander Birkner 
wrote:
>
> Hello,
>
> we are migrating our existing backend from PHP to Ruby.
> We are using Sequel with Models but we can't do some queries because there 
> is no way to use the MySQL function UNIX_TIMESTAMP.
>
> I would like to create a query like this:
>
> Service.where(
> :field_1 => 0,
> :field_2 => 0,
> :field_3 => Service::SERVICE_STATUS_ACTIVE,
> ).where{
>   (suspend_date - Sequel::UNIX_TIMESTAMP) > 0
> }.where {
>   (suspend_date - Sequel::UNIX_TIMESTAMP) < time
>
> }
>
>
> I've seen there is already existing a CURRENT_TIMESTAMP constant but this 
> does not work in our case. 
> The existing database field is a int instead of a datetime field.
>
> It would be really awesome if Sequel will add the UNIX_TIMESTAMP mysql 
> method for Model queries.
>
> I've done it temporary with using a timestamp variable (timestamp = 
> DateTime.now.to_i)
> but I would recommend to use the MySQL server time instead of the API 
> server time.
>
> Thank you very much!
>

I don't plan on adding specific support for this in Sequel, it seems to be 
a MySQL specific thing.  It's just a regular function call anyway, you can 
just use Sequel's function support:

Service.where(
:field_1 => 0,
:field_2 => 0,
:field_3 => Service::SERVICE_STATUS_ACTIVE).
  where{suspend_date - UNIX_TIMESTAMP{} > 0}.
  where{suspend_date - UNIX_TIMESTAMP{} < time}

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To post to this group, send email to sequel-talk@googlegroups.com.
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.


Re: Feature Request: UNIX_TIMESTAMP

2016-10-12 Thread Austin Ziegler
Couldn’t use use Sequel.function(:unix_timestamp)? It’s been a few months
since I’ve written DB code, but that seems like it would work.

-a

On Wed, Oct 12, 2016 at 1:09 PM, Alexander Birkner 
wrote:

> Hello,
>
> we are migrating our existing backend from PHP to Ruby.
> We are using Sequel with Models but we can't do some queries because there
> is no way to use the MySQL function UNIX_TIMESTAMP.
>
> I would like to create a query like this:
>
> Service.where(
> :field_1 => 0,
> :field_2 => 0,
> :field_3 => Service::SERVICE_STATUS_ACTIVE,
> ).where{
>   (suspend_date - Sequel::UNIX_TIMESTAMP) > 0
> }.where {
>   (suspend_date - Sequel::UNIX_TIMESTAMP) < time
>
> }
>
>
> I've seen there is already existing a CURRENT_TIMESTAMP constant but this
> does not work in our case.
> The existing database field is a int instead of a datetime field.
>
> It would be really awesome if Sequel will add the UNIX_TIMESTAMP mysql
> method for Model queries.
>
> I've done it temporary with using a timestamp variable (timestamp =
> DateTime.now.to_i)
> but I would recommend to use the MySQL server time instead of the API
> server time.
>
> Thank you very much!
>
> --
> You received this message because you are subscribed to the Google Groups
> "sequel-talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sequel-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to sequel-talk@googlegroups.com.
> Visit this group at https://groups.google.com/group/sequel-talk.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Austin Ziegler • halosta...@gmail.com • aus...@halostatue.ca
http://www.halostatue.ca/ • http://twitter.com/halostatue

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To post to this group, send email to sequel-talk@googlegroups.com.
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.


Feature Request: UNIX_TIMESTAMP

2016-10-12 Thread Alexander Birkner
Hello,

we are migrating our existing backend from PHP to Ruby.
We are using Sequel with Models but we can't do some queries because there 
is no way to use the MySQL function UNIX_TIMESTAMP.

I would like to create a query like this:

Service.where(
:field_1 => 0,
:field_2 => 0,
:field_3 => Service::SERVICE_STATUS_ACTIVE,
).where{
  (suspend_date - Sequel::UNIX_TIMESTAMP) > 0
}.where {
  (suspend_date - Sequel::UNIX_TIMESTAMP) < time

}


I've seen there is already existing a CURRENT_TIMESTAMP constant but this 
does not work in our case. 
The existing database field is a int instead of a datetime field.

It would be really awesome if Sequel will add the UNIX_TIMESTAMP mysql 
method for Model queries.

I've done it temporary with using a timestamp variable (timestamp = 
DateTime.now.to_i)
but I would recommend to use the MySQL server time instead of the API 
server time.

Thank you very much!

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To post to this group, send email to sequel-talk@googlegroups.com.
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.