Data Types - full360/sneaql GitHub Wiki

Boolean

As of 0.0.13, SneaQL supports boolean values. You can specify a boolean literal using true or false as show below:

/*-assign varname true-*/

Note that you do not need to put true in single quotes.

When performing comparisons, you can use either true/false... one of several string literals... or a 0/1 integer to compare against a boolean:

/*-exit_if :varname = true-*/
/*-exit_if :varname = 't'-*/
/*-exit_if :varname = 'true'-*/
/*-exit_if :varname = 1-*/

Note that one of the comparators must be a boolean value. The following example will not work because both values are string literals, which will cause them to be compared as strings:

--DOES NOT WORK...
--strings are only converted to boolean
--if the other value is an actual boolean object
/*-assign varname 'true'-*/
/*-exit_if :varname = 't'-*/

Dates and Timestamps

As of 0.0.14, SneaQL supports dates and timestamps for comparison.

/*-assign_result sysdate-*/
select sysdate();

/*-exit_if :sysdate < '2001-07-01'-*/

Dates or timestamp definitions in command tags must be made as a string literal. Please note that the object will remain a string literal until it is used in a comparison to a date/timestamp field or value, at which point it will be converted.

Considerations when using these data types:

  • Date or timestamp fields returned from database queries will be converted to a jruby Time object for use in comparisons.
  • When performing a comparison, you can compare your date/timestamp field to another date/timestamp, or to a string that can be parsed into a jruby Time object.
  • Any value brought into SneaQL that does not have a time zone associated with it will be assigned the time zone of the local machine. This is true for dates as well as timestamps. The best results will come from running SneaQL with the same time zone as your database.

You can use the TZ environment variable to set the time zone of your SneaQL process, without changing the system time of your local machine.

TZ=UTC

If you are using the standard SneaQL docker image, your timezone will default to UTC unless you pass in the TZ environment variable to your container at run time.