Fix param-extraction

This commit is contained in:
Kane York 2015-06-30 16:43:43 -07:00
parent a81f8495b0
commit baeb747fcb
2 changed files with 8 additions and 4 deletions

View File

@ -1,6 +1,6 @@
<h3>Queries</h3> <h3>Queries</h3>
<div class="query-list"> <div class="query-list">
{{combo-box valueAttribute="id" value=selectedQueryId nameProperty="listName" content=content castInteger="true"}} {{combo-box valueAttribute="id" value=selectedQueryId nameProperty="listName" content=content castInteger="true" nameChanges="true"}}
{{d-button action="showCreate" icon="plus" class="no-text"}} {{d-button action="showCreate" icon="plus" class="no-text"}}
{{d-button action="importQuery" label="explorer.import.label" icon="upload"}} {{d-button action="importQuery" label="explorer.import.label" icon="upload"}}
</div> </div>

View File

@ -47,9 +47,13 @@ after_initialize do
# (The first name is $0.) # (The first name is $0.)
def self.extract_params(sql) def self.extract_params(sql)
names = [] names = []
new_sql = sql.gsub(/:([a-z_]+)/) do |_| new_sql = sql.gsub(/(:?):([a-z_]+)/) do |_|
names << $1 if $1 == ':' # skip casts
"$#{names.length - 1}" $&
else
names << $1
"$#{names.length - 1}"
end
end end
{sql: new_sql, names: names} {sql: new_sql, names: names}
end end