quill (scala library) generate query that correct for Oracle 12, but not for Oracle 11

118 Views Asked by At

I must work with 2 different databases:

Oracle 11.2.0.3.0
Oracle 12.2.0.1.0

Using quill-jdbc-zio 4.6.0 (and zio 2.0.12 scala 2.13.10) I found that quill generate queries with using FETCH FIRST 2 ROWS ONLY that is no applicabe to Oracle 11.

import io.getquill._

val ctx = new SqlMirrorContext(OracleDialect, SnakeCase)

import ctx._

case class Person(id: Int, name: String, age: Int)

val m = ctx.run(query[Person].sortBy(p => p.id).take(2))

println(m.string)

output

SELECT p.id, p.name, p.age FROM person p ORDER BY p.id ASC NULLS FIRST FETCH FIRST 2 ROWS ONLY

This query is successful executing in Oracle 12 and raise ORA-00933: SQL command not properly ended in Oracle 11.

Can I use different settings of quill for 11 and 12? Or can I configure datasource?

I suppose for Oracle 11 it must be generated something like this:

  select id, name, age
  from ( select a.*, rownum rnum
           from ( 
                  ---------------------
                  SELECT p.id, p.name, p.age FROM person p ORDER BY p.id ASC NULLS FIRST
                  ---------------------
                ) a
          where rownum <= 2)
   where rnum >= 1

scastie

1

There are 1 best solutions below

0
On

Apparently no.


From the Quill Contexts documentation:

Oracle (quill-jdbc)

Quill supports Oracle version 12c and up although due to licensing restrictions, version 18c XE is used for testing.

and:

Oracle (quill-jdbc-zio)

Quill supports Oracle version 12c and up although due to licensing restrictions, version 18c XE is used for testing.

and:

Oracle (quill-jdbc-monix)

Quill supports Oracle version 12c and up although due to licensing restrictions, version 18c XE is used for testing.

It would appear that Quill does not support Oracle 11 and below.