On Jan 16, 2012, at 11:46 AM, werner wrote:

> I would like to do this type of thing:
> 
> namesandvar = column_property(names + " " + variety)
> 
> and use it e.g. like:
> 
> query(db.Cellarbook).filter(db.Drinkinfo.namesandvar.contains(u'menu'))
> 
> But Firebird SQL doesn't like the "+" operator, it throws an error "Strings 
> cannot be added or subtracted in dialect 3".
> 
> Is there an alternative which would work for both FB and Postgresql?

the + should be coming out as || if "names" and "variety" are both of String 
type.



> 
> Werner
> 
> P.S.
> The above query generates the following:
> 2012-01-16 17:41:56,696 INFO sqlalchemy.engine.base.Engine SELECT 
> cellarbook.id AS cellarbook_id, cellarbook.maturityfirst AS 
> cellarbook_maturityfirst, cellarbook.maturitybest AS cellarbook_maturitybest, 
> cellarbook.maturitypast AS cellarbook_maturitypast, 
> cellarbook.storagelocation AS cellarbook_storagelocation, 
> cellarbook.quantitypurchased AS cellarbook_quantitypurchased, 
> cellarbook.quantityconsumed AS cellarbook_quantityconsumed, 
> cellarbook.quantityonhand AS cellarbook_quantityonhand, 
> cellarbook.lastpurchaseprice AS cellarbook_lastpurchaseprice, 
> cellarbook.avgpurchaseprice AS cellarbook_avgpurchaseprice, 
> cellarbook.currentvalue AS cellarbook_currentvalue, cellarbook.isactive AS 
> cellarbook_isactive, cellarbook.printlabel AS cellarbook_printlabel, 
> cellarbook.minqoh AS cellarbook_minqoh, cellarbook.avgscore AS 
> cellarbook_avgscore, cellarbook.avgscore2 AS cellarbook_avgscore2, 
> cellarbook.fk_cellar_id AS cellarbook_fk_cellar_id, cellarbook.fk_authuser_id 
> AS cellarbook_fk_authuser_id, cell
> arbook.fk_bottle_id AS cellarbook_fk_bottle_id, cellarbook.fk_vintage_id AS 
> cellarbook_fk_vintage_id, cellarbook.fk_drinkinfo_id AS 
> cellarbook_fk_drinkinfo_id, cellarbook.fk_cbbottleid AS 
> cellarbook_fk_cbbottleid, cellarbook.created_at AS cellarbook_created_at, 
> cellarbook.updated_at AS cellarbook_updated_at, cellarbook.created_by AS 
> cellarbook_created_by, cellarbook.updated_by AS cellarbook_updated_by, 
> cellar_1.id AS cellar_1_id, cellar_1.name AS cellar_1_name, 
> cellar_1.fk_authuser_id AS cellar_1_fk_authuser_id, cellar_1.created_at AS 
> cellar_1_created_at, cellar_1.updated_at AS cellar_1_updated_at, 
> cellar_1.created_by AS cellar_1_created_by, cellar_1.updated_by AS 
> cellar_1_updated_by, authuser_1."password" AS authuser_1_password, 
> authuser_1.id AS authuser_1_id, authuser_1.name AS authuser_1_name, 
> authuser_1.email AS authuser_1_email, authuser_1.displayname AS 
> authuser_1_displayname, authuser_1.fk_language_id AS 
> authuser_1_fk_language_id, authuser_1.fk_cellar_id AS authuser_1_fk_cellar_
> id, authuser_1.created_at AS authuser_1_created_at, authuser_1.updated_at AS 
> authuser_1_updated_at, authuser_1.created_by AS authuser_1_created_by, 
> authuser_1.updated_by AS authuser_1_updated_by, bottle_1.id AS bottle_1_id, 
> bottle_1.remarks AS bottle_1_remarks, bottle_1.barcode AS bottle_1_barcode, 
> bottle_1.inetrefcode AS bottle_1_inetrefcode, bottle_1.inetrefsource AS 
> bottle_1_inetrefsource, bottle_1.quantitypurchased AS 
> bottle_1_quantitypurchased, bottle_1.quantityconsumed AS 
> bottle_1_quantityconsumed, bottle_1.lastpurchaseprice AS 
> bottle_1_lastpurchaseprice, bottle_1.avgpurchaseprice AS 
> bottle_1_avgpurchaseprice, bottle_1.currentvalue AS bottle_1_currentvalue, 
> bottle_1.fk_vintage_id AS bottle_1_fk_vintage_id, bottle_1.fk_container_id AS 
> bottle_1_fk_container_id, bottle_1.fk_sealtype_id AS bottle_1_fk_sealtype_id, 
> bottle_1.created_at AS bottle_1_created_at, bottle_1.updated_at AS 
> bottle_1_updated_at, bottle_1.created_by AS bottle_1_created_by, 
> bottle_1.updated_by AS bottle_1_updated_
> by, vintage_1.id AS vintage_1_id, vintage_1.vintage AS vintage_1_vintage, 
> vintage_1.notes AS vintage_1_notes, vintage_1.alcohol AS vintage_1_alcohol, 
> vintage_1.avgscore AS vintage_1_avgscore, vintage_1.avgscore2 AS 
> vintage_1_avgscore2, vintage_1.locurl AS vintage_1_locurl, vintage_1.url AS 
> vintage_1_url, vintage_1.fk_drinkinfo_id AS vintage_1_fk_drinkinfo_id, 
> vintage_1.fk_wineinfo_id AS vintage_1_fk_wineinfo_id, 
> vintage_1.fk_spirinfo_id AS vintage_1_fk_spirinfo_id, vintage_1.created_at AS 
> vintage_1_created_at, vintage_1.updated_at AS vintage_1_updated_at, 
> vintage_1.created_by AS vintage_1_created_by, vintage_1.updated_by AS 
> vintage_1_updated_by, drinkinfo_1.id AS drinkinfo_1_id, drinkinfo_1.name AS 
> drinkinfo_1_name, drinkinfo_1.name2 AS drinkinfo_1_name2, 
> drinkinfo_1.barrique AS drinkinfo_1_barrique, drinkinfo_1.externalref AS 
> drinkinfo_1_externalref, drinkinfo_1.notes AS drinkinfo_1_notes, 
> drinkinfo_1.variety AS drinkinfo_1_variety, drinkinfo_1.fk_country_id AS 
> drinkinfo_1_fk_country_
> id, drinkinfo_1.fk_region_id AS drinkinfo_1_fk_region_id, 
> drinkinfo_1.fk_subregion_id AS drinkinfo_1_fk_subregion_id, 
> drinkinfo_1.fk_minregion_id AS drinkinfo_1_fk_minregion_id, 
> drinkinfo_1.fk_supplier_id AS drinkinfo_1_fk_supplier_id, 
> drinkinfo_1.fk_producer_id AS drinkinfo_1_fk_producer_id, 
> drinkinfo_1.fk_distiller_id AS drinkinfo_1_fk_distiller_id, 
> drinkinfo_1.fk_bottler_id AS drinkinfo_1_fk_bottler_id, 
> drinkinfo_1.fk_quality_id AS drinkinfo_1_fk_quality_id, 
> drinkinfo_1.fk_drinktype_id AS drinkinfo_1_fk_drinktype_id, 
> drinkinfo_1.fk_winestyle_id AS drinkinfo_1_fk_winestyle_id, 
> drinkinfo_1.created_at AS drinkinfo_1_created_at, drinkinfo_1.updated_at AS 
> drinkinfo_1_updated_at, drinkinfo_1.created_by AS drinkinfo_1_created_by, 
> drinkinfo_1.updated_by AS drinkinfo_1_updated_by 
> FROM drinkinfo, cellarbook LEFT OUTER JOIN cellar AS cellar_1 ON cellar_1.id 
> = cellarbook.fk_cellar_id LEFT OUTER JOIN authuser AS authuser_1 ON 
> authuser_1.id = cellarbook.fk_authuser_id LEFT OUTER JOIN bottle AS bottle_1 
> ON bottle_1.id = cellarbook.fk_bottle_id LEFT OUTER JOIN vintage AS vintage_1 
> ON vintage_1.id = cellarbook.fk_vintage_id LEFT OUTER JOIN drinkinfo AS 
> drinkinfo_1 ON drinkinfo_1.id = cellarbook.fk_drinkinfo_id 
> WHERE drinkinfo.name + ? + drinkinfo.name2 + (? || drinkinfo.variety) LIKE 
> '%%' || ? || '%%'
> 2012-01-16 17:41:56,696 INFO sqlalchemy.engine.base.Engine (', ', ', ', 
> 'menu')
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> To unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to