Note that there are some explanatory texts on larger screens.

plurals
  1. POGrails get() generating incomplete SQL
    text
    copied!<p>I'm upgrading an app from Grails 1.3.6 to 2.1.1. Have hit what seems to be a very strange issue. </p> <p>I have a table called SECTION. This call:</p> <pre><code>def testSection = Section.get(94725) </code></pre> <p>Generates this SQL in Grails 1.3.6:</p> <pre><code>select section0_.ID as ID42_0_, section0_.concept_tag_uri as concept2_42_0_, section0_.INDEX_ID as INDEX3_42_0_, section0_.LIVE_IND as LIVE4_42_0_, section0_.NAME as NAME42_0_, section0_.PARENT_ID as PARENT6_42_0_, section0_.ASST_INDEX_ASSET_ID as ASST7_42_0_, section0_.ORDER_NO as ORDER8_42_0_, section0_.SITE_ID as SITE9_42_0_, section0_.TYPE_ID as TYPE10_42_0_, (SELECT uk_sec.id FROM section uk_sec, site uk_site WHERE uk_sec.index_id = section0_.index_id AND uk_sec.site_id = uk_site.siteid AND uk_site.audienceid = 1) as formula1_0_ from SECTION section0_ where section0_.ID=? </code></pre> <p>But this SQL in 2.1.1:</p> <pre><code>select section0_.ID as ID45_0_, section0_.concept_tag_uri as concept2_45_0_, section0_.INDEX_ID as INDEX3_45_0_, section0_.LIVE_IND as LIVE4_45_0_, section0_.NAME as NAME45_0_, section0_.PARENT_ID as PARENT6_45_0_, section0_.ASST_INDEX_ASSET_ID as ASST7_45_0_, section0_.ORDER_NO as ORDER8_45_0_, section0_.SITE_ID as SITE9_45_0_, (SELECT uk_sec.id FROM section uk_sec, site uk_site WHERE uk_sec.index_id = section0_.index_id AND uk_sec.site_id = uk_site.siteid AND uk_site.audienceid = 1) as formula1_0_ from SECTION section0_ where section0_.ID=? </code></pre> <p>Looks similar, but this part is missing in the 2.1.1 version:</p> <pre><code>section0_.TYPE_ID as TYPE10_42_0_, </code></pre> <p>This is the mapping in the class:</p> <pre><code>... String sectionType ... static mapping = { table 'SECTION' version false id generator:'assigned' columns { ... sectionType column: 'TYPE_ID' ... } } </code></pre> <p>The DB field in question is: TYPE_ID CHAR(1) but as the SQL is generated as a result of the get(), am assuming it's nothing to do with the actual DB schema or column(?). </p> <p>The fact that it's the final element in the list of select fields makes me think it's somehow related, but I don't know how to change that, or if doing so would just 'delete' another field from the statement.</p> <p>Anyone seen anything like this?</p> <p>Cheers, spacebot</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload