def test_user_function_name_completion_matches_anywhere(self, completer):
        result = result_set(completer, 'SELECT om')
        self.assertSetEqual(result, set([
            function('custom_fun()', -2),
            function('_custom_fun()', -2),
            function('custom_func1()', -2),

            function('custom_func2()', -2)]))
 def test_user_function_name_completion(self, completer):
     result = result_set(completer, 'SELECT cu')
     self.assertSetEqual(result, set([
         function('custom_fun()', -2),
         function('_custom_fun()', -2),
         function('custom_func1()', -2),
         function('custom_func2()', -2),
         keyword('CURRENT', -2),
     ]))
Esempio n. 3
0
 def test_schema_qualified_function_name(self, completer):
     text = 'SELECT custom.func'
     result = result_set(completer, text)
     self.assertSetEqual(
         result,
         set([
             function('func3()', -len('func')),
             function('set_returning_func()', -len('func'))
         ]))
Esempio n. 4
0
 def test_table_casing(self, completer, text):
     result = result_set(completer, text)
     self.assertSetEqual(
         result,
         set(CASED_SCHEMAS + [
             table('users'),
             table('Orders'),
             table('"select"'),
             function('Func1()'),
             function('func2()')
         ]))
Esempio n. 5
0
 def test_aliases_with_casing(self, completer, text):
     result = result_set(completer, text)
     self.assertSetEqual(
         result,
         set(CASED_SCHEMAS + [
             table('users u'),
             table('Orders O' if text == 'SELECT * FROM ' else 'Orders O2'),
             table('"select" s'),
             function('Func1() F'),
             function('func2() f')
         ]))
Esempio n. 6
0
 def test_table_aliases(self, completer, text):
     result = result_set(completer, text)
     self.assertSetEqual(
         result,
         set(TESTDATA.schemas() + [
             table('users u'),
             table('orders o' if text == 'SELECT * FROM ' else 'orders o2'),
             table('"select" s'),
             function('func1() f'),
             function('func2() f')
         ]))
Esempio n. 7
0
 def test_all_schema_objects(self, completer):
     text = ('SELECT * FROM ')
     result = result_set(completer, text)
     # Note: set comparison >= means is superset
     self.assertTrue(result >= set(
         [table(x) for x in ('orders', '"select"', 'custom.shipments')] +
         [function(x + '()') for x in ('func2', 'custom.func3')]))
 def test_duplicate_table_aliases(self, completer, text):
     result = result_set(completer, text)
     self.assertSetEqual(result, set(testdata.schemas() + [
         table('orders o2'),
         table('users u'),
         table('"Users" U'),
         table('"select" s'),
         view('user_emails ue'),
         view('functions f'),
         function('_custom_fun() cf'),
         function('custom_fun() cf'),
         function('custom_func1() cf'),
         function('custom_func2() cf'),
         function(
             'set_returning_func(x := , y := ) srf',
             display='set_returning_func(x, y) srf'
         ),
     ]))
Esempio n. 9
0
 def test_builtin_function_name_completion(self, completer):
     result = result_set(completer, 'SELECT MA')
     self.assertSetEqual(
         result,
         set([
             function('MAX', -2),
             keyword('MAXEXTENTS', -2),
             keyword('MATERIALIZED VIEW', -2)
         ]))
 def test_duplicate_aliases_with_casing(self, completer, text):
     result = result_set(completer, text)
     self.assertSetEqual(result, set([
         schema('PUBLIC'),
         table('Orders O2'),
         table('Users U'),
         table('"Users" U'),
         table('"select" s'),
         view('User_Emails UE'),
         view('Functions F'),
         function('_custom_fun() cf'),
         function('Custom_Fun() CF'),
         function('Custom_Func1() CF'),
         function('custom_func2() cf'),
         function(
             'set_returning_func(x := , y := ) srf',
             display='set_returning_func(x, y) srf'
         ),
     ]))
 def test_drop_alter_function(self, completer, action):
     self.assertListEqual(get_result(completer, action + ' FUNCTION set_ret'),
                          [function('set_returning_func(x integer, y integer)', -len('set_ret'))])
testdata = MetaData(METADATA)

cased_users_col_names = ['ID', 'PARENTID', 'Email', 'First_Name', 'last_name']
cased_users2_col_names = ['UserID', 'UserName']
cased_func_names = [
    'Custom_Fun', '_custom_fun', 'Custom_Func1', 'custom_func2', 'set_returning_func'
]
cased_tbls = ['Users', 'Orders']
cased_views = ['User_Emails', 'Functions']
casing = (
    ['SELECT', 'PUBLIC'] + cased_func_names + cased_tbls + cased_views
    + cased_users_col_names + cased_users2_col_names
)
# Lists for use in assertions
cased_funcs = [
    function(f) for f in ('Custom_Fun()', '_custom_fun()', 'Custom_Func1()', 'custom_func2()')
] + [function('set_returning_func(x := , y := )', display='set_returning_func(x, y)')]
cased_tbls = [table(t) for t in (cased_tbls + ['"Users"', '"select"'])]
cased_rels = [view(t) for t in cased_views] + cased_funcs + cased_tbls
cased_users_cols = [column(c) for c in cased_users_col_names]
aliased_rels = [
    table(t) for t in ('users u', '"Users" U', 'orders o', '"select" s')
] + [view('user_emails ue'), view('functions f')] + [
    function(f) for f in (
        '_custom_fun() cf', 'custom_fun() cf', 'custom_func1() cf',
        'custom_func2() cf'
    )
] + [function(
    'set_returning_func(x := , y := ) srf',
    display='set_returning_func(x, y) srf'
)]
Esempio n. 13
0
testdata = MetaData(METADATA)

cased_users_col_names = ['ID', 'PARENTID', 'Email', 'First_Name', 'last_name']
cased_users2_col_names = ['UserID', 'UserName']
cased_func_names = [
    'Custom_Fun', '_custom_fun', 'Custom_Func1', 'custom_func2',
    'set_returning_func'
]
cased_tbls = ['Users', 'Orders']
cased_views = ['User_Emails', 'Functions']
casing = (['SELECT', 'PUBLIC'] + cased_func_names + cased_tbls + cased_views +
          cased_users_col_names + cased_users2_col_names)
# Lists for use in assertions
cased_funcs = [
    function(f) for f in ('Custom_Fun()', '_custom_fun()', 'Custom_Func1()',
                          'custom_func2()')
] + [
    function('set_returning_func(x := , y := )',
             display='set_returning_func(x, y)')
]
cased_tbls = [table(t) for t in (cased_tbls + ['"Users"', '"select"'])]
cased_rels = [view(t) for t in cased_views] + cased_funcs + cased_tbls
cased_users_cols = [column(c) for c in cased_users_col_names]
aliased_rels = [
    table(t) for t in ('users u', '"Users" U', 'orders o', '"select" s')
] + [view('user_emails ue'), view('functions f')] + [
    function(f) for f in ('_custom_fun() cf', 'custom_fun() cf',
                          'custom_func1() cf', 'custom_func2() cf')
] + [
    function('set_returning_func(x := , y := ) srf',
Esempio n. 14
0
 def test_all_schema_objects_with_aliases(self, completer):
     text = ('SELECT * FROM ')
     result = result_set(completer, text)
     self.assertTrue(result >= set([
         table(x) for x in ('orders o', '"select" s', 'custom.shipments s')
     ] + [function(x) for x in ('func2() f', 'custom.func3() f')]))
Esempio n. 15
0
 def test_all_schema_objects_with_casing(self, completer):
     text = 'SELECT * FROM '
     result = result_set(completer, text)
     self.assertTrue(result >= set(
         [table(x) for x in ('Orders', '"select"', 'CUSTOM.shipments')] +
         [function(x + '()') for x in ('func2', 'CUSTOM.func3')]))