Skip to content

Instantly share code, notes, and snippets.

@demoth
Created November 19, 2013 07:28
Show Gist options
  • Save demoth/7541605 to your computer and use it in GitHub Desktop.
Save demoth/7541605 to your computer and use it in GitHub Desktop.
def line = querry.replaceAll('\n','')
switch (line) {
case { it.startsWith('SELECT') }:
return (line =~ /(?<=SELECT)(.*)(?=FROM)/)[0][0].replaceAll(/[`\s]/, '').tokenize(',')
case { it.startsWith('INSERT') }:
return (line =~ /(?<=\()(.*)(?=\) VALUES)/)[0][0].replaceAll(/[`\s/, '').tokenize(',')
case { it.startsWith('UPDATE') }:
return (line =~ /(?<=SET)(.*)(?=WHERE)/)[0][0].replaceAll(/[=`\?\s]/, '').tokenize(',')
default:
println 'WARNING! Unknown querry type!' + querry
return []
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment