|
|
@@ -162,6 +162,27 @@ class TestCustomFunctionsPostgres(FrappeTestCase): |
|
|
|
'"tabnote"."posting_date"+"tabnote"."posting_time" "timestamp"', str(select_query).lower() |
|
|
|
) |
|
|
|
|
|
|
|
def test_time(self): |
|
|
|
note = frappe.qb.DocType("Note") |
|
|
|
|
|
|
|
self.assertEqual( |
|
|
|
"CAST('2021-01-01' AS DATE)+CAST('00:00:21' AS TIME)", |
|
|
|
CombineDatetime("2021-01-01", time(0, 0, 21)).get_sql(), |
|
|
|
) |
|
|
|
|
|
|
|
select_query = frappe.qb.from_(note).select( |
|
|
|
CombineDatetime(note.posting_date, note.posting_time) |
|
|
|
) |
|
|
|
self.assertIn('select "posting_date"+"posting_time"', str(select_query).lower()) |
|
|
|
|
|
|
|
select_query = select_query.where( |
|
|
|
CombineDatetime(note.posting_date, note.posting_time) |
|
|
|
>= CombineDatetime("2021-01-01", time(0, 0, 1)) |
|
|
|
) |
|
|
|
self.assertIn("""where "posting_date"+"posting_time">=cast('2021-01-01' as date)+cast('00:00:01' as time)""", |
|
|
|
str(select_query).lower(), |
|
|
|
) |
|
|
|
|
|
|
|
def test_cast(self): |
|
|
|
note = frappe.qb.DocType("Note") |
|
|
|
self.assertEqual("CAST(name AS VARCHAR)", Cast_(note.name, "varchar").get_sql()) |
|
|
|