Possible problem with tests?

6 views
Skip to first unread message

yair

unread,
Jan 8, 2011, 9:59:09 PM1/8/11
to clj-record-dev
Hi,

I'm new to clj-record. I've recently cloned the repository and added
basic db2 support by adding a multimethod for "get-id-key-spec" and
for "id-query-for" with the db2 protocol. I'm having a minor problem
running the tests. After running db-reset and then the tests, there
are occasional errors in some of the tests which I believe are caused
by the order in which db2 fetches records. The test "clj-record.core-
test/find-record-returns-the-first-matching-record" fails consistently
right after reset-db and I believe this is because two records are
created in it and the test expects the first one to be retrieved based
on the query parameter which should find both records. This seems to
be highly susceptible to the way the db returns the records, as it
simply does a "first" on the resulting records for the parameter. I'm
not sure what the purpose of this test is, as there is no real concept
of "first valid record" unless a sort is put into the query.

Thanks,
Yair

John D. Hume

unread,
Jan 9, 2011, 2:11:40 AM1/9/11
to clj-rec...@googlegroups.com
I think you're right. That query should provide ordering to be
reliable across DB vendors.

I'm in Uganda slammed with another project right now, but if you can
add the relevant ordering to the query along with the db2 support and
submit a pull request on Github I should be able to get to it next
weekend (and at least anyone else will be able to see your fix if it's
relevant to them).

--
http://elhumidor.blogspot.com/

yair

unread,
Jan 9, 2011, 6:42:00 PM1/9/11
to clj-record-dev
Will do John. I'll add ordering by ID into the find-record query, as
that is the closest thing to "first" record. Are there any plans on
adding actual user specified ordering into queries? I'd be happy to
take a look at implementing that, but would be interested to know if
you already have thoughts on how to implement this.

Cheers,
Yair

John D. Hume

unread,
Jan 10, 2011, 1:31:39 AM1/10/11
to clj-rec...@googlegroups.com
What I think I'd really like to do is get clj-record out of the
business of generating SQL itself and use ClojureQL, at the same time
modifying the clj-record API to expose some of ClojureQL directly. As
a less radical alternative in the meantime, I suppose I'd favor an
optional additional argument to find-record and find-records that
could look like this:
{:order "id ASC"}
or
{:order "category DESC, name ASC"}

--
http://elhumidor.blogspot.com/

Daniel Renfer

unread,
Jan 10, 2011, 9:21:31 AM1/10/11
to clj-rec...@googlegroups.com
I forked clj-record a while back to add support for limiting and
ordering. The project has moved on since then and my original code
will most likely not work.

The problem I had, at the time was figuring out how to deal with
backends that don't support some features. In particular, I was using
MySQL as my db of choce, while the tests used Derby. IIRC, Derby
didn't support limiting in the same way that MySQL did.

+1 to making clj-record a layer on top of ClojureQL.

Reply all
Reply to author
Forward
0 new messages