def test_get_type(self):
f = lambda sql: sqlparse.parse(sql)[0]
self.assertEqual(f('select * from foo').get_type(), 'SELECT')
self.assertEqual(f('update foo').get_type(), 'UPDATE')
self.assertEqual(f(' update foo').get_type(), 'UPDATE')
self.assertEqual(f('\nupdate foo').get_type(), 'UPDATE')
self.assertEqual(f('foo').get_type(), 'UNKNOWN')
# Statements that have a whitespace after the closing semicolon
# are parsed as two statements where later only consists of the
# trailing whitespace.
self.assertEqual(f('\n').get_type(), 'UNKNOWN')
评论列表
文章目录