Slick driver for Ingres

55 views
Skip to first unread message

Ivan Grebenik

unread,
Apr 27, 2015, 9:10:44 AM4/27/15
to scala...@googlegroups.com
Hello there! 

I'm trying to write a slick driver for Ingres 10.x and 57 tests pass successfully out of 88 but still I've run in few problems I want you to give advices for me.

The problem is how Ingres extracts current value form a sequence. First of all, it has CURRVAL and NEXTVAL to work around sequence values. Then CURRVAL is not populated until after NEXTVAL has been used...

Here is an example.

* create sequence "s1" increment by 1 start with 11 maxvalue 1000 nocache nocycle;\g
* select "s1".CURRVAL;\g

I get the "E_QE00A2 An attempt to issue a CURRENT VALUE request on a sequence was made before issuing a NEXT VALUE request."

So if I issue the NEXTVAL beforehand when it works fine:

* select "s1".NEXTVAL;\g

I get 11,
and then do CURRENT VALUE:

* select "s1".CURRVAL;
and now I get the 11.

Due to this specific behavior the tests under com.typesafe.slick.testkit.tests.SequenceTest.test1 failed. 
To be more precise,

ifCap(scap.sequenceCurr) {
    val curr = mySequence.curr.run // this code fails
    assertEquals(220, curr)
}

It is not big deal to disable this feature at the testing side but how can I workaround it in the driver itself?

Just to override expr method doesn't look like it solve the issue here.

class QueryBuilder(tree: Node, state: CompilerState) extends super.QueryBuilder(tree, state) {
    protected override val supportsTuples = false
    protected override val concatOperator = Some("||")
    protected override val hasPiFunction = true // since version 9.2

    override def expr(n: Node, skipParens: Boolean = false) = n match {
      case Library.NextValue(SequenceNode(name))    => b"${quoteIdentifier(name)}.NEXTVAL"
      case Library.CurrentValue(SequenceNode(name)) => b"${quoteIdentifier(name)}.CURRVAL" 
      case _ => super.expr(n, skipParens)
    }
  }

How could I override the select quiery behavior to comply to Ingres one?

Thanks in advance.

Ivan Grebenik

unread,
Apr 28, 2015, 3:30:19 AM4/28/15
to scala...@googlegroups.com
BTW, I use slick 2.1.0
Reply all
Reply to author
Forward
0 new messages