Mar 01, 2017; 10:55
Jolle Carlestam
Gist with array -> encodesql
Greetings!
I’ve added a gist with a method to run encodesql on each item in a provided array or staticarray.
Can be found here:
https://gist.github.com/jolle-c/693b0cb599482a34d0cf8ee7d59e9fbc
This is the code:
/**!
array -> encodesql
Adds a method to the lasso 9 array and staticarray types that will run encodesql on each item in the array.
This changes the array in place.
It also alters each item to type string.
EXAMPLE USAGE
local(ids = array('1', '5', '22'))
local(sql = "SELECT * FROM mytable AS mt
WHERE mt.id IN ('" + #ids -> encodesql& -> join("', '") + "');")
*/
define array -> encodesql() => {
loop(.size) => {
if(.get(loop_count) -> isa(::pair)) => {
.get(loop_count) = pair(.get(loop_count) -> first -> asstring -> encodesql, .get(loop_count) -> second -> asstring -> encodesql)
else
.get(loop_count) = .get(loop_count) -> asstring -> encodesql
}
}
}
define staticarray -> encodesql() => {
loop(.size) => {
if(.get(loop_count) -> isa(::pair)) => {
.get(loop_count) = pair(.get(loop_count) -> first -> asstring -> encodesql, .get(loop_count) -> second -> asstring -> encodesql)
else
.get(loop_count) = .get(loop_count) -> asstring -> encodesql
}
}
}
--------------------
Hope it can be use use for someone.
HDB
Jolle
#############################################################
This message is sent to you because you are subscribed to
the mailing list Lasso Lasso@lists.lassosoft.com
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <Lasso-unsubscribe@lists.lassosoft.com>
Send administrative queries to <Lasso-request@lists.lassosoft.com>
Apr 19, 2017; 11:16
russell
Re: Gist with array -> encodesql