示例#1
0
    def getManufactureNull(self):
        products = Table('products', 'eg_product_staging')
        q = Query.from_(products).select('*').where(
            fn.IsNull(products.manufacturer_id)
            | products.manufacturer_id == '')

        records = self.db.fetchall(q.get_sql())
        return records
示例#2
0
    def getProductNotTitle(self):
        products = Table('products', 'eg_product_staging')
        product_translations = Table('product_translations',
                                     'eg_product_staging')
        mst_rc_syouhin_multi = Table('mst_rc_syouhin_multi',
                                     'rc_products_multi')

        q = Query.from_(products).join(
            product_translations, how=JoinType.left
        ).on(products.id == product_translations.product_id).join(
            mst_rc_syouhin_multi, how=JoinType.left).on(
                products.sku == mst_rc_syouhin_multi.syouhin_sys_code).select(
                    products.sku, product_translations.locale,
                    product_translations.name, products.name,
                    mst_rc_syouhin_multi.name.as_('sync_multi_name')).where(
                        fn.IsNull(product_translations.name)
                        & products.active == 1)

        records = self.db.fetchall(q.get_sql())
        return records
示例#3
0
    def test_isnull(self):
        q = Q.from_('abc').select(fn.IsNull(F('foo')))

        self.assertEqual('SELECT ISNULL(\"foo\") FROM \"abc\"', str(q))
示例#4
0
    def test_function_xor(self):
        c1 = fn.IsNull(Field("foo")) ^ (Field("bar") == 2)

        self.assertEqual('ISNULL("foo") XOR "bar"=2', str(c1))
示例#5
0
    def test_function_and(self):
        c1 = fn.IsNull(Field("foo")) & (Field("bar") == 2)

        self.assertEqual('ISNULL("foo") AND "bar"=2', str(c1))
示例#6
0
    def test_function_or(self):
        c1 = fn.IsNull(Field('foo')) | (Field('bar') == 2)

        self.assertEqual('ISNULL("foo") OR "bar"=2', str(c1))
示例#7
0
    def test_isnull(self):
        q = Q.from_("abc").select(fn.IsNull(F("foo")))

        self.assertEqual('SELECT ISNULL("foo") FROM "abc"', str(q))