Skip to content

Commit 227699e

Browse files
akurungadamdevelopmentforpeople
authored andcommitted
test: add test for postgres
1 parent 9564fa4 commit 227699e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

frappe/tests/test_query_builder.py

+21
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,27 @@ def test_timestamp(self):
162162
'"tabnote"."posting_date"+"tabnote"."posting_time" "timestamp"', str(select_query).lower()
163163
)
164164

165+
def test_time(self):
166+
note = frappe.qb.DocType("Note")
167+
168+
self.assertEqual(
169+
"CAST('2021-01-01' AS DATE)+CAST('00:00:21' AS TIME)",
170+
CombineDatetime("2021-01-01", time(0, 0, 21)).get_sql(),
171+
)
172+
173+
select_query = frappe.qb.from_(note).select(
174+
CombineDatetime(note.posting_date, note.posting_time)
175+
)
176+
self.assertIn('select "posting_date"+"posting_time"', str(select_query).lower())
177+
178+
select_query = select_query.where(
179+
CombineDatetime(note.posting_date, note.posting_time)
180+
>= CombineDatetime("2021-01-01", time(0, 0, 1))
181+
)
182+
self.assertIn("""where "posting_date"+"posting_time">=cast('2021-01-01' as date)+cast('00:00:01' as time)""",
183+
str(select_query).lower(),
184+
)
185+
165186
def test_cast(self):
166187
note = frappe.qb.DocType("Note")
167188
self.assertEqual("CAST(name AS VARCHAR)", Cast_(note.name, "varchar").get_sql())

0 commit comments

Comments
 (0)