Revision 9467
Added by Aaron Marcuse-Kubitza over 11 years ago
db.sh | ||
---|---|---|
20 | 20 |
mk_esc_name_alias schema_esc |
21 | 21 |
mk_esc_name_alias table_esc |
22 | 22 |
|
23 |
limit() # usage: query... $([prefix=$'| |\n'] limit) |
|
24 |
{ |
|
25 |
echo_func; kw_params prefix; local prefix="${prefix- |
|
26 |
}" |
|
27 |
echo -n "${limit:+${prefix}LIMIT $limit}" |
|
28 |
} |
|
29 |
|
|
23 | 30 |
# export func usage: export_func() { ...; mk_select_var; ... } |
24 | 31 |
# caller usage: {query=... | table=... [cols=...] [filter=...]} export_func |
25 | 32 |
# cmd line usage: [limit=...] caller |
... | ... | |
27 | 34 |
declare query="$(rtrim "${query:-SELECT ${cols:-*} ${cols:+ |
28 | 35 |
}FROM $table_esc |
29 | 36 |
${filter:+WHERE $filter |
30 |
}}") |
|
31 |
${limit:+LIMIT $limit}"
|
|
37 |
}}")\
|
|
38 |
$(limit)"
|
|
32 | 39 |
' |
33 | 40 |
|
34 | 41 |
fi # load new aliases |
Also available in: Unified diff
lib/sh/db.sh: added limit() and use it instead of `${limit:+LIMIT $limit}`