jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • groovy
  • GROOVY-1916

I need to get the metaData even when I get no results/I'd like an easier way to get the metaData from the Sql class.

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Wish Wish
  • Status: Closed Closed
  • Priority: Trivial Trivial
  • Resolution: Fixed
  • Affects Version/s: 1.0-beta-1
  • Fix Version/s: 1.1-beta-2
  • Component/s: groovy-jdk, SQL processing
  • Labels:
    None
  • Environment:
    suse linux 10.0, jdk 1.6, but it probably affects all systems.

Description

I was not able to find a way to get sql metadata even when there are no rows returned
with the current Groovy sql stuff, so I subclassed groovy.sql.Sql and added a new
version of eachRow and rows such that each takes an additional "metaClosure" so
that I can feed the metaClosure the result set's meta data. that way, even if I don't have any
rows returned, I can be sure to have the meta data. And I don't have to
delve into the row processing closure to get the meta data from the first row
or anything like that.

I made my own subclass and added the following methods:

public List rows( final String sql,
final Closure metaClosure )

public void eachRow( final String sql,
final Closure metaClosure,
final Closure rowClosure )

So now I can:

def metaData
def results = sql.rows( query ) { metaData = it }

I didn't make a groovier version of the metadata class the way there's a
GroovyRowResult and GroovyResultSet class. I was very impressed with how
easy it was to do what I needed to do.

I have attached the methods I added, but they are not in the approved groovy format.

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Java Source File
    Sql.java
    25/May/07 8:29 PM
    3 kB
    Thomas R. Corbin

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
blackdrag blackdrag added a comment - 24/Jun/07 11:54 AM

patch applied

Show
blackdrag blackdrag added a comment - 24/Jun/07 11:54 AM patch applied
Hide
Permalink
Paul King added a comment - 17/Jan/08 2:54 AM

Additional component added to Jira issue for historical searching

Show
Paul King added a comment - 17/Jan/08 2:54 AM Additional component added to Jira issue for historical searching

People

  • Assignee:
    blackdrag blackdrag
    Reporter:
    Thomas R. Corbin
Vote (0)
Watch (0)

Dates

  • Created:
    25/May/07 8:29 PM
    Updated:
    17/Jan/08 2:54 AM
    Resolved:
    17/Jan/08 2:54 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.