SQLAlchemy"或"具有多个参数的语句

时间:2015-05-08 12:02:32

标签: python sqlalchemy

我的查询需要使用"或" |运营商:

Mymodel.query.filter((Mymodel.a== 'b') | (Mymodel.b == 'c'))

工作正常。但是,我希望将我的条件放入一个未知长度的数组中:

conds = [ Mymodel.a== 'b', Mymodel.b == 'c', Mymodel.c == 'd']
Mymodel.query.filter(???(conds))

谢谢!

1 个答案:

答案 0 :(得分:6)

您正在寻找or_

@Override
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
    if (!( lpparam.packageName.equals("com.android.systemui") || lpparam.packageName.equals("com.android.settings"))) {
        return;
    }
    XposedBridge.log("Loaded app: " + lpparam.packageName);
    final Class<?> mClass = XposedHelpers.findClass("android.provider.Settings$System", lpparam.classLoader);
    findAndHookMethod(mClass, "putInt", ContentResolver.class, String.class, "int",  new XC_MethodHook() {
        @Override
        protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
            XposedBridge.log("In android.provider.Settings.System");
        }
    });
}

如果你有上述条件列表,只需将它们全部传递给_或

conds = [ Mymodel.a== 'b', Mymodel.b == 'c', Mymodel.c == 'd']