Exemplo n.º 1
0
 def test_simple_match(self):
     query = self.session.query(self.Character.name) \
                 .filter(match(self.Character.name, 'Trillian'))
     self.assertSQL(
         "SELECT characters.name AS characters_name FROM characters WHERE match(characters.name, 'Trillian')",
         query
     )
Exemplo n.º 2
0
 def test_match_boost(self):
     query = self.session.query(self.Character.name) \
             .filter(match({self.Character.name: 0.5}, 'Trillian'))
     self.assertSQL(
         "SELECT characters.name AS characters_name FROM characters WHERE match((characters.name 0.5), 'Trillian')",
         query
     )
Exemplo n.º 3
0
 def test_muli_match(self):
     query = self.session.query(self.Character.name) \
             .filter(match({self.Character.name: 0.5,
                            self.Character.info['race']: 0.9},
                           'Trillian'))
     self.assertSQL(
         "SELECT characters.name AS characters_name FROM characters WHERE match((characters.info['race'] 0.9, characters.name 0.5), ?)",
         query)
Exemplo n.º 4
0
 def test_match_boost(self):
     query = self.session.query(self.Character.name) \
         .filter(match({self.Character.name: 0.5}, 'Trillian'))
     self.assertSQL(
         "SELECT characters.name AS characters_name FROM characters " +
         "WHERE match((characters.name 0.5), ?)",
         query
     )
Exemplo n.º 5
0
 def test_simple_match(self):
     query = self.session.query(self.Character.name) \
                 .filter(match(self.Character.name, 'Trillian'))
     self.assertSQL(
         "SELECT characters.name AS characters_name FROM characters " +
         "WHERE match(characters.name, ?)",
         query
     )
Exemplo n.º 6
0
 def test_score(self):
     query = self.session.query(self.Character.name, '_score') \
                 .filter(match(self.Character.name, 'Trillian'))
     self.assertSQL(
         "SELECT characters.name AS characters_name, _score " +
         "FROM characters WHERE match(characters.name, ?)",
         query
     )
Exemplo n.º 7
0
 def test_muli_match(self):
     query = self.session.query(self.Character.name) \
             .filter(match({self.Character.name: 0.5,
                            self.Character.info['race']: 0.9},
                           'Trillian'))
     self.assertSQL(
         "SELECT characters.name AS characters_name FROM characters WHERE match((characters.info['race'] 0.9, characters.name 0.5), 'Trillian')",
         query
     )
Exemplo n.º 8
0
 def test_match_type_options(self):
     query = self.session.query(self.Character.name) \
             .filter(match({self.Character.name: 0.5,
                            self.Character.info['race']: 0.9},
                           'Trillian',
                           match_type='phrase',
                           options={'fuzziness': 3, 'analyzer': 'english'})
                    )
     self.assertSQL(
         "SELECT characters.name AS characters_name FROM characters WHERE match((characters.info['race'] 0.9, characters.name 0.5), ?) using phrase with (analyzer=english, fuzziness=3)",
         query)
Exemplo n.º 9
0
 def test_match_type_options(self):
     query = self.session.query(self.Character.name) \
             .filter(match({self.Character.name: 0.5,
                            self.Character.info['race']: 0.9},
                           'Trillian',
                           match_type='phrase',
                           options={'fuzziness': 3, 'analyzer': 'english'})
                    )
     self.assertSQL(
         "SELECT characters.name AS characters_name FROM characters WHERE match((characters.info['race'] 0.9, characters.name 0.5), 'Trillian') using phrase with (analyzer=english, fuzziness=3)",
         query
     )
Exemplo n.º 10
0
 def test_options_without_type(self):
     query = self.session.query(self.Character.name) \
             .filter(match({self.Character.name: 0.5,
                            self.Character.info['race']: 0.9},
                           'Trillian',
                           options={'boost': 10.0})
                    )
     err = None
     try:
         str(query)
     except ValueError as e:
         err = e
     self.assertEquals(str(err),
                       "missing match_type. It's not allowed to specify options without match_type")
Exemplo n.º 11
0
 def test_options_without_type(self):
     query = self.session.query(self.Character.name).filter(
         match({self.Character.name: 0.5, self.Character.info['race']: 0.9},
               'Trillian',
               options={'boost': 10.0})
     )
     err = None
     try:
         str(query)
     except ValueError as e:
         err = e
     msg = "missing match_type. " + \
           "It's not allowed to specify options without match_type"
     self.assertEquals(str(err), msg)