Exemple #1
0
 def test_when_alias_specified(self):
     query = Query.from_("customers").select(
         AtTimezone("date", "US/Eastern", alias="alias1"))
     self.assertEqual(
         'SELECT "date" AT TIME ZONE \'US/Eastern\' "alias1" FROM "customers"',
         str(query),
     )
Exemple #2
0
 def test_when_interval_specified(self):
     query = Query.from_("customers").select(
         AtTimezone("date", "-06:00", interval=True))
     self.assertEqual(
         'SELECT "date" AT TIME ZONE INTERVAL \'-06:00\' FROM "customers"',
         str(query),
     )
Exemple #3
0
    def test_passes_kwargs_to_field_get_sql(self):
        customers = Table("customers")
        accounts = Table("accounts")
        query = (Query.from_(customers).join(accounts).on(
            customers.account_id == accounts.account_id).select(
                AtTimezone(customers.date, "US/Eastern", alias="alias1")))

        self.assertEqual(
            'SELECT "customers"."date" AT TIME ZONE \'US/Eastern\' "alias1" '
            'FROM "customers" JOIN "accounts" ON "customers"."account_id"="accounts"."account_id"',
            query.get_sql(with_namespace=True),
        )
Exemple #4
0
 def test_when_interval_not_specified(self):
     query = Query.from_("customers").select(
         AtTimezone("date", "US/Eastern"))
     self.assertEqual(
         'SELECT "date" AT TIME ZONE \'US/Eastern\' FROM "customers"',
         str(query))