Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play framework, PostgreSQL in memory database, interval not working

I can't get the following request to work with Play framework

SELECT DISTINCT tableName 
    FROM hand 
    WHERE (hand.userLogin = {userLogin} OR {userLogin} IS NULL)
    AND (date >= now() - interval '3 days')
    ORDER BY tableName

I tested it on a PostreSQL database and it works perfectly, however when I try to run in in dev mode it does not work, I get the following error:

Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "SELECT DISTINCT TABLENAME FROM HAND WHERE (HAND.USERLOGIN = ? OR ? IS NULL) AND (DATE >= CURRENT_TIMESTAMP - INTERVAL '3 minute'[*]) ORDER BY TABLENAME "; expected "., (, [, ::, *, /, %, +, -, ||, ~, !~, (, NOT, LIKE, REGEXP, IS, IN, BETWEEN, AND, OR, ,, )";

my conf file says:

db.default.driver=org.h2.Driver
db.default.url="jdbc:h2:mem:play;MODE=PostgreSQL"

I don't know what I am getting wrong. Removing the interval part makes it work so it is obviously the problem.

like image 422
Bentaye Avatar asked Jul 26 '26 04:07

Bentaye


1 Answers

Postgres interval does not belong to H2 standard, thus it is not supported by H2. See h2 grammar doc for supported functions and keywords.

like image 172
Mon Calamari Avatar answered Jul 28 '26 05:07

Mon Calamari



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!