GithubHelp home page GithubHelp logo

Comments (10)

lukaseder avatar lukaseder commented on May 29, 2024

You cannot pass a condition to Factory.nullIf(). As specified in the MySQL docs, both arguments have to be expressions (i.e. org.jooq.Field, or T, which is any value that can be passed to Factory.val()). In jOOQ, a condition is not an expression/field

How are you calling nullif() ?

Maybe it would make sense to extend jOOQ in a way to allow org.jooq.Condition to be used as a Field across the API?

from jooq.

dacc avatar dacc commented on May 29, 2024

Ah ok, that must be why. Yes, being able to "cast" Conditions as a Field would be handy!

from jooq.

lukaseder avatar lukaseder commented on May 29, 2024

OK, that idea will be tracked as:
#1178

It might mean substantial change, as a lot of new integration tests would be needed, so I can't promise when this will be done.

Cheers
Lukas

from jooq.

dacc avatar dacc commented on May 29, 2024

Ok sure. My work-around was to simply drop down to raw SQL, which wasn't too bad.

This often comes up when you want to count rows that match a certain condition. COUNT(NULLIF([condition], false)) is a handy way to do so, but maybe I could use a case(?)

from jooq.

lukaseder avatar lukaseder commented on May 29, 2024

Yes, a CASE expression would be the most SQL-like style:

SUM(CASE WHEN [condition] THEN 1 ELSE 0 END)

I tend to feel that the NULLIF construct is a bit less readable. But I'm not so used to MySQL, so maybe it's common practice there? Still, it's a good use case for #1178

from jooq.

dacc avatar dacc commented on May 29, 2024

Oh yeah, not sure why I didn't do it that way -- I'll try it out tomorrow.

from jooq.

dacc avatar dacc commented on May 29, 2024

Worked great of course. Cheers!

from jooq.

lukaseder avatar lukaseder commented on May 29, 2024

Glad it works!

I allowed myself to cite your nice feedback from Stack Overflow directly on my blog, if that is OK with you?
http://lukaseder.wordpress.com/2012/03/02/jooq-compared-to-ibatis/

from jooq.

dacc avatar dacc commented on May 29, 2024

Sure, feel free to use the second comment too. I've been meaning to write a more thorough testimonial if that would be useful.

from jooq.

lukaseder avatar lukaseder commented on May 29, 2024

Yes, any success story (e.g. on your personal / company blog) is very welcome! If you have the time, I'd be interested in a more detailed pro / con comparison between jOOQ / iBATIS for your specific use case. Such a comparison could be a base for further discussion and feature requests in jOOQ...

Cheers
Lukas

from jooq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.