On Mon, May 30, 2011 at 11:27 PM, Patrick Earl <pate...@patearl.net> wrote:

> Greetings!
>
> I have the following query:
>
> SELECT this_.studentId as studentId143_0_, this_.Name as Name143_0_,
> this_.address_city as address3_143_0_, this_.address_state as
> address4_143_0_, this_.preferredCourseCode as preferre5_143_0_ FROM
> Student this_ WHERE this_.Name = (SELECT this_0_.Name as y0_ FROM
> Student this_0_ WHERE this_0_.studentId = @p0 ORDER BY this_0_.Name
> asc limit @p1)
>
> sqlite3_bind_parameter_count returns 2.
>
> sqlite3_bind_parameter_name(1) returns @p0
> sqlite3_bind_parameter_name(2) returns "", not @p1
>

Actually, it returns NULL, not "".

The LIMIT in a scalar subquery is always ignored.  A scalar subquery
operates with a LIMIT of 1 regardless of any LIMIT that you might specify.
That means the @p1 is optimized out - it does not appear in the generated
code for the prepared statement.  Any parameter that is optimized out
becomes an anonymous parameter for which sqlite3_bind_parameter_name returns
NULL.

The documentation has been updated to clarify the above points.  Thanks for
bringing it to our attention.


>
> Perhaps this is related to being a limit in a subquery.
>
> Though nobody may care, this is currently preventing the NHibernate
> test suite from passing.
>
> Appreciate your help with this. :)
>
>         Patrick Earl
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
D. Richard Hipp
d...@sqlite.org
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to