Re: Null values in query parameters

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Sep 23 2009 - 07:26:27 EDT

  • Next message: Andrus Adamchik: "Re: Making sense of callbacks"

    I see. Yeah, like I said I am also not a fan of #bindEqual. It was a
    hack back in the day to address "column = value" vs "column is null"
    syntax differences. Let's investigate what it takes to make #bind work.

    Andrus

    On Sep 23, 2009, at 1:45 PM, Evgeny Ryabitskiy wrote:

    > No! #bindEqual can't help me...
    > I am using something like this:
    >
    > INSERT INTO TABLE1 (id, NullableColumn) values (10, $MyNullValue)
    >
    > And in param MyNullValue I put null, It's legal to insert null in
    > this column.
    > So I can't use #bindEqual here, the only solution to pass
    > (String)"null" as parametr... but I don't wan't to put everywhere in
    > my code such constructions:
    > (paramValue == null) ? "null" : paramValue
    >
    > It is possible to do this check on perform query level.... Going to
    > make some changes to cayenne againg....
    >
    > Best regards,
    > Evgeny Ryabitskiy.
    >
    >
    > 2009/9/23 Eugene R. <apparition07..mail.com>:
    >> No! #bindEqual can't help me...
    >> I am using something like this:
    >>
    >> INSERT INTO TABLE1 (id, NullableColumn) values (10, $MyNullValue)
    >>
    >> And in param MyNullValue I put null, It's legal to insert null in
    >> this column.
    >> So I can't use #bindEqual here, the only solution to pass
    >> (String)"null" as parametr... but I don't wan't to put everywhere in
    >> my code such constructions:
    >> (paramValue == null) ? "null" : paramValue
    >>
    >> It is possible to do this check on perform query level.... Going to
    >> make some changes to cayenne againg....
    >>
    >> Best regards,
    >> Evgeny Ryabitskiy.
    >>
    >>
    >> 2009/9/23 Andrus Adamchik <andru..bjectstyle.org>:
    >>> Hi Evgeny,
    >>>
    >>> To address NULL's syntax issues, there are special directives
    >>> "#bindEqual
    >>> and #bindNotEqual". See "Null Values in Bindings - #bindEqual and
    >>> #bindNotEqual Directives" here:
    >>>
    >>> http://cayenne.apache.org/doc/scripting-sqltemplate.html
    >>>
    >>> I can't say I am a big fan of the above solution, and maybe we
    >>> should be
    >>> smarter in SQLTemplateAction about NULL's in #bind directives.
    >>> Some research
    >>> is needed here.
    >>>
    >>> Andrus
    >>>
    >>>
    >>>
    >>> On Sep 23, 2009, at 12:55 PM, Evgeny Ryabitskiy wrote:
    >>>
    >>>> Hello to everyone!
    >>>>
    >>>> I have a problem with passing null params to SQLTemplate.
    >>>>
    >>>> So.. I put null to params, then perform query and got... bad formed
    >>>> SQL query...
    >>>> I know it's because of how Velocity Engine do merge for templates.
    >>>> I know that I can use construction like this: #bind('valueKey'
    >>>> 'jdbcType'
    >>>> null)
    >>>> But this query is generated and I don't know jdbcType :/
    >>>>
    >>>> Also I don't want to pass (java.lang.String) "null" in parameters
    >>>> or
    >>>> my Java code will be huge.
    >>>>
    >>>> Looks like there is no simple way to force cayenne inserting null
    >>>> in
    >>>> templates. Or I am missing something?
    >>>>
    >>>> Maybe we can add some flag for query SQLTemplate constructor.. like
    >>>> boolean "convertNulls" to allow passing nulls in params without
    >>>> huge
    >>>> template changes
    >>>> ( I mean inserting everywhere #bind('valueKey' 'jdbcType' null) ) ?
    >>>>
    >>>>
    >>>> Best regards,
    >>>> Evgeny Ryabitskiy.
    >>>>
    >>>
    >>>
    >>
    >



    This archive was generated by hypermail 2.0.0 : Wed Sep 23 2009 - 07:27:11 EDT