Skip to content

Commit

Permalink
Tweaks for 9.3 compatibility (works around multiple dispatch differen…
Browse files Browse the repository at this point in the history
…ces)
  • Loading branch information
Ke- committed Apr 20, 2015
1 parent 831ba0d commit 9e7a8be
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 52 deletions.
44 changes: 22 additions & 22 deletions ds.lasso
Expand Up @@ -245,14 +245,14 @@ define ds => type{
else(#host)
// Host specified, skip look up — fast
#dsinfo->hostdatasource = #datasource
#dsinfo->hostid = 0
#dsinfo->hostname = #host
#dsinfo->hostport = #port->asstring
#dsinfo->hostusername = #username
#dsinfo->hostpassword = #password
#dsinfo->hosttableencoding = #encoding
#dsinfo->hostschema = #schema
#dsinfo->hostdatasource = #datasource
#dsinfo->hostid = 0
#dsinfo->hostname = #host
#dsinfo->hostport = #port->asstring
#dsinfo->hostusername = #username
#dsinfo->hostpassword = #password
#dsinfo->hosttableencoding = #encoding
#dsinfo->hostschema = #schema
.'capi' = \#datasource
Expand Down Expand Up @@ -685,7 +685,7 @@ define ds => type{
| return (:.'keycolumn')
}
public keycolumns=(keycolumns::trait_foreach) => {
public keycolumns=(keycolumns::trait_positionallykeyed) => {
.'dsinfo'->keycolumns = (
with col in #keycolumns
select .keyvalue(#col = null)
Expand All @@ -697,7 +697,7 @@ define ds => type{
public keycolumns(key::string,...) => .keycolumns((with p in params select #p)->asstaticarray)
public keycolumns(key::tag,...) => .keycolumns((with p in params select #p->asstring)->asstaticarray)
public keycolumns(keycolumns::trait_foreach) => {
public keycolumns(keycolumns::trait_positionallykeyed) => {
.keycolumns = #keycolumns
return self
}
Expand All @@ -718,7 +718,7 @@ define ds => type{
return (with p in #keys->eachpair select .keyvalue(#p))->asstaticarray
}
private keyvalues(keys::trait_foreach) => {
private keyvalues(keys::trait_positionallykeyed) => {
return (with p in #keys select .keyvalue(#p))->asstaticarray
}
Expand All @@ -732,7 +732,7 @@ define ds => type{
//
//---------------------------------------------------------------------------------------
private inputcolumns(p::trait_foreach) => {
private inputcolumns(p::trait_positionallykeyed) => {
local(input) = array
#p->foreach => {
Expand Down Expand Up @@ -870,10 +870,10 @@ define ds => type{
//
//---------------------------------------------------------------------------------------
public addrow(p::pair,...) => .execute(::add,.table,staticarray,params,true) => givenblock
public addrow(p::trait_keyedforeach) => .execute(::add,.table,staticarray,#p->eachpair->asstaticarray,true) => givenblock
public addrow(p::trait_foreach) => .execute(::add,.table,staticarray,#p->asstaticarray,true) => givenblock
public addrow(data::staticarray) => .execute(::add,.table,staticarray,#data,true) => givenblock
public addrow(p::pair,...) => .execute(::add,.table,staticarray,params,true) => givenblock
public addrow(p::trait_keyedforeach) => .execute(::add,.table,staticarray,#p->eachpair->asstaticarray,true) => givenblock
public addrow(p::trait_positionallykeyed) => .execute(::add,.table,staticarray,#p->asstaticarray,true) => givenblock
public addrow(data::staticarray) => .execute(::add,.table,staticarray,#data,true) => givenblock
public addrow(totable::string,data::trait_keyedforeach) => .execute(::add,
#totable,
Expand Down Expand Up @@ -982,14 +982,14 @@ define ds => type{
public getrows(keyvalue,...) => .getfrom(.table,params)
public getrows(keyvalue::pair,p::pair,...) => .getfrom(.table,params)
public getrows(keyvalues::trait_foreach) => .getfrom(.table,#keyvalues)
public getrows(keyvalues::trait_positionallykeyed) => .getfrom(.table,#keyvalues)
public getfrom(table::tag,keyvalue::any) => .getfrom(#table->asstring,#keyvalue)
public getfrom(table::string,keyvalue::string) => .execute(::search,#table,.keyvalues(.keycolumn=#keyvalue),staticarray)->rows
public getfrom(table::string,keyvalue::integer) => .execute(::search,#table,.keyvalues(.keycolumn=#keyvalue),staticarray)->rows
public getfrom(table::string,key::pair) => .execute(::search,#table,.keyvalues(#key),staticarray)->rows
public getfrom(table::string,keyvalues::trait_foreach) => {
public getfrom(table::string,keyvalues::trait_positionallykeyed) => {
local(
matchall = false,
params = array(
Expand Down Expand Up @@ -1086,13 +1086,13 @@ define ds => type{
public insert(table::tag,...columns) => .insert_statement->into(#table,#columns) => givenblock
public insert(table::string,...columns) => .insert_statement->into(#table,#columns) => givenblock
public insert(table::tag,columns::trait_foreach) => .insert_statement->into(#table,#columns) => givenblock
public insert(table::string,columns::trait_foreach) => .insert_statement->into(#table,#columns) => givenblock
public insert(table::tag,columns::trait_positionallykeyed) => .insert_statement->into(#table,#columns) => givenblock
public insert(table::string,columns::trait_positionallykeyed) => .insert_statement->into(#table,#columns) => givenblock
public update(table::tag,...where) => .update_statement->update(#table,#where) => givenblock
public update(table::string,...where) => .update_statement->update(#table,#where) => givenblock
public update(table::tag,where::trait_foreach) => .update_statement->update(#table,#where) => givenblock
public update(table::string,where::trait_foreach) => .update_statement->update(#table,#where) => givenblock
public update(table::tag,where::trait_positionallykeyed) => .update_statement->update(#table,#where) => givenblock
public update(table::string,where::trait_positionallykeyed) => .update_statement->update(#table,#where) => givenblock
public update(...) => .update_statement->set(:#rest || staticarray) => givenblock
public set(...) => .update_statement->set(:#rest || staticarray) => givenblock
Expand Down
6 changes: 3 additions & 3 deletions ds_result.lasso
Expand Up @@ -31,8 +31,8 @@ define result_pop => thread_var_pop(::__ds_results)
define ds_result => type {
data
public index::trait_searchable,
public cols::trait_foreach,
public types::trait_foreach,
public cols::trait_positionallykeyed,
public types::trait_positionallykeyed,
public rows::staticarray,
public set::staticarray,
public found::integer=0,
Expand Down Expand Up @@ -116,7 +116,7 @@ define ds_result => type {
public oncreate(
index::trait_searchable,
cols::trait_foreach,
cols::trait_positionallykeyed,
rows::staticarray,
set::staticarray,
found::integer=0,
Expand Down
6 changes: 3 additions & 3 deletions ds_row.lasso
Expand Up @@ -71,20 +71,20 @@ define ds_row => type{
.'row' = staticarray
}
public oncreate(index::trait_searchable,cols::trait_foreach,row::staticarray,dsinfo::null=null,ds::null=null)=>{
public oncreate(index::trait_searchable,cols::trait_positionallykeyed,row::staticarray,dsinfo::null=null,ds::null=null)=>{
.'index'= #index
.'cols' = #cols
.'row' = #row
}
public oncreate(index::trait_searchable,cols::trait_foreach,row::staticarray,dsinfo::dsinfo)=>{
public oncreate(index::trait_searchable,cols::trait_positionallykeyed,row::staticarray,dsinfo::dsinfo)=>{
.'index' = #index
.'cols' = #cols
.'row' = #row
.'dsinfo' = #dsinfo
}
public oncreate(index::trait_searchable,cols::trait_foreach,row::staticarray,dsinfo::dsinfo,ds::ds)=>{
public oncreate(index::trait_searchable,cols::trait_positionallykeyed,row::staticarray,dsinfo::dsinfo,ds::ds)=>{
.'index' = #index
.'cols' = #cols
.'row' = #row
Expand Down
2 changes: 1 addition & 1 deletion sequential.lasso
Expand Up @@ -26,7 +26,7 @@ define sequential_node => type {
define sequential => type {
trait {
import trait_contractible, trait_searchable, trait_expandable, trait_keyed, trait_foreach, trait_keyedforeach
import trait_contractible, trait_searchable, trait_expandable, trait_keyed, trait_foreach, trait_positionallykeyed, trait_keyedforeach
}
data
Expand Down
55 changes: 32 additions & 23 deletions statement.lasso
Expand Up @@ -80,7 +80,7 @@ define statement => type {
//
//---------------------------------------------------------------------------------------
public switch(target::tag,value::trait_foreach) => {
public switch(target::tag,value::trait_positionallykeyed) => {
(.escape_member(tag(`'`+#target->asstring+`'=`)))->invoke(#value)
return .invokeifblock => givenblock
}
Expand Down Expand Up @@ -131,9 +131,9 @@ define statement => type {
public encodecol(col::string) => {
#col = #col->ascopy
#col->replace(';','')
.ismysql ? #col->replace('`','') & replace('.','`.`')
return '`' + #col + '`'
.ismysql ? #col = '`' + #col->replace('`','') & replace('.','`.`')& + '`'
return #col
}
public ismysql => protect => {
Expand All @@ -147,7 +147,7 @@ define statement => type {
//---------------------------------------------------------------------------------------
public ifsize(p::null,...) => ''
public ifsize(p::trait_foreach,pre::string,join::string='',suf::string='') => {
public ifsize(p::trait_positionallykeyed,pre::string,join::string='',suf::string='') => {
if(#p->size) => {
return #pre + #p->join(#join) + #suf + '\n'
else
Expand All @@ -166,14 +166,14 @@ define select_statement => type {
parent statement
data
public select::trait_foreach = array,
public from::trait_foreach = array,
public join::trait_foreach = array,
public where::trait_foreach = array,
public groupby::trait_foreach = array,
public having::trait_foreach = array,
public orderby::trait_foreach = array,
public limit::trait_foreach = array
public select::trait_positionallykeyed = array,
public from::trait_positionallykeyed = array,
public join::trait_positionallykeyed = array,
public where::trait_positionallykeyed = array,
public groupby::trait_positionallykeyed = array,
public having::trait_positionallykeyed = array,
public orderby::trait_positionallykeyed = array,
public limit::trait_positionallykeyed = array
public oncreate => {}
public oncreate(ds::ds) => {
Expand Down Expand Up @@ -397,12 +397,12 @@ define insert_statement => type {
public into(table::string,...columns) => .switch(::into,array(#table))->merge(::columns,#columns || staticarray) => givenblock
public into(table::tag,...columns) => .switch(::into,array(#table->asstring))->merge(::columns,#columns || staticarray) => givenblock
public into(table::string,columns::trait_foreach) => .switch(::into,array(#table))->merge(::columns,#columns->asstaticarray) => givenblock
public into(table::tag,columns::trait_foreach) => .switch(::into,array(#table->asstring))->merge(::columns,#columns->asstaticarray) => givenblock
public into(table::string,columns::trait_positionallykeyed) => .switch(::into,array(#table))->merge(::columns,#columns->asstaticarray) => givenblock
public into(table::tag,columns::trait_positionallykeyed) => .switch(::into,array(#table->asstring))->merge(::columns,#columns->asstaticarray) => givenblock
public columns(column::tag,...) => .merge(::columns,params) => givenblock
public columns(column::string,...) => .merge(::columns, params) => givenblock
public columns(columns::trait_foreach) => .switch(::columns,#columns->asarray) => givenblock
public columns(columns::trait_positionallykeyed) => .switch(::columns,#columns->asarray) => givenblock
public merge(target::tag,values::staticarray) => {
match(#target) => {
Expand All @@ -419,7 +419,16 @@ define insert_statement => type {
}
public into => .ifsize(.'into', 'INSERT' + (.delayed ? ' DELAYED ') + (.ignore ? ' IGNORE ') + ' INTO ', ',')
public columns => .ifsize(.'columns', '(', ',', ')')
public columns => {
return .'columns'->size
? '(' + (with col in .'columns'
select .encodecol(#col)
)->asstaticarray->join(',') + ')'
| ''
}
public values => .ifsize(.'values', 'VALUES ',',\n')
public onduplicate => .ifsize(.'onduplicate', 'ON DUPLICATE KEY UPDATE ',',\n')
Expand Down Expand Up @@ -458,7 +467,7 @@ define insert_statement => type {
// If no columns specified use the maps keys
.'columns'->size == 0
? with col in #p->keys do {
.'columns'->insert(.encodecol(#col))
.'columns'->insert(#col)
}
// Only use data from specified columns
Expand Down Expand Up @@ -503,7 +512,7 @@ define insert_statement => type {
//
//---------------------------------------------------------------------------------------
public addrows(rows::trait_foreach) => {
public addrows(rows::trait_positionallykeyed) => {
#rows->foreach => {
.addrow(#1)
}
Expand Down Expand Up @@ -608,10 +617,10 @@ define update_statement => type {
parent statement
data
public update::trait_foreach = array,
public join::trait_foreach = array,
public set::trait_foreach = array,
public where::trait_foreach = array
public update::trait_positionallykeyed = array,
public join::trait_positionallykeyed = array,
public set::trait_positionallykeyed = array,
public where::trait_positionallykeyed = array
public oncreate => {}
public oncreate(ds::ds) => {
Expand Down

0 comments on commit 9e7a8be

Please sign in to comment.