def filter(self, trans, user, query, dbkey): """ Filter by dbkey through a raw SQL b/c metadata is a BLOB. """ dbkey_user, dbkey = decode_dbkey(dbkey) dbkey = dbkey.replace("'", "\\'") return query.filter( or_("metadata like '%%\"dbkey\": [\"%s\"]%%'" % dbkey, "metadata like '%%\"dbkey\": \"%s\"%%'" % dbkey))
def filter( self, trans, user, query, dbkey ): """ Filter by dbkey; datasets without a dbkey are returned as well. """ # use raw SQL b/c metadata is a BLOB dbkey_user, dbkey = decode_dbkey( dbkey ) dbkey = dbkey.replace("'", "\\'") return query.filter( or_( \ or_( "metadata like '%%\"dbkey\": [\"%s\"]%%'" % dbkey, "metadata like '%%\"dbkey\": \"%s\"%%'" % dbkey ), \ or_( "metadata like '%%\"dbkey\": [\"?\"]%%'", "metadata like '%%\"dbkey\": \"?\"%%'" ) \ ) )
def filter( self, trans, user, query, dbkey ): """ Filter by dbkey. """ # Use raw SQL b/c metadata is a BLOB. dbkey_user, dbkey = decode_dbkey( dbkey ) dbkey = dbkey.replace("'", "\\'") return query.filter( or_( "metadata like '%%\"dbkey\": [\"%s\"]%%'" % dbkey, "metadata like '%%\"dbkey\": \"%s\"%%'" % dbkey ) )