Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-224

Variable declartion with type gets lost in closure

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.0-beta-4
    • None
    • None

    Description

      import org.axiondb.jdbc.AxionDataSource

      class GroovySQLTest extends GroovyTestCase {

      void testGroovySQL() {
      dataSource = new AxionDataSource("jdbc:axiondb:foo" + getMethodName());
      sql = new groovy.sql.Sql(dataSource);

      sql.execute("create table groovytest ( anint integer, astring varchar )");

      groovytest = sql.dataSet("groovytest")
      groovytest.add( anint:1, astring:"Groovy" )
      groovytest.add( anint:2, astring:"rocks" )

      // this line messes up things:
      Integer id = 0;

      sql.eachRow("SELECT * FROM groovytest ORDER BY anint")

      { id = it.anint; }

      assert id == 2;
      }
      }

      id = 0; works

      Integer id; doesn't but generates a different error

      Attachments

        Activity

          People

            jstrachan James Strachan
            maniax Thomas Heller
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: