@@ -183,104 +183,6 @@ def returning_clause(self, stmt, returning_cols):
183183 ]
184184 return "RETURNING " + ", " .join (columns )
185185
186- def visit_insert (self , insert_stmt , asfrom = False , ** kw ):
187- """
188- used to compile <sql.expression.Insert> expressions.
189-
190- this function wraps insert_from_select statements inside
191- parentheses to be conform with earlier versions of CreateDB.
192- """
193-
194- self .stack .append (
195- {'correlate_froms' : set (),
196- "asfrom_froms" : set (),
197- "selectable" : insert_stmt })
198-
199- self .isinsert = True
200- crud_params = crud ._get_crud_params (self , insert_stmt , ** kw )
201-
202- if not crud_params and \
203- not self .dialect .supports_default_values and \
204- not self .dialect .supports_empty_insert :
205- raise NotImplementedError (
206- "The '%s' dialect with current database version settings does "
207- "not support empty inserts." % self .dialect .name )
208-
209- if insert_stmt ._has_multi_parameters :
210- if not self .dialect .supports_multivalues_insert :
211- raise NotImplementedError (
212- "The '%s' dialect with current database "
213- "version settings does not support "
214- "in-place multirow inserts." % self .dialect .name )
215- crud_params_single = crud_params [0 ]
216- else :
217- crud_params_single = crud_params
218-
219- preparer = self .preparer
220- supports_default_values = self .dialect .supports_default_values
221-
222- text = "INSERT "
223-
224- if insert_stmt ._prefixes :
225- text += self ._generate_prefixes (insert_stmt ,
226- insert_stmt ._prefixes , ** kw )
227-
228- text += "INTO "
229- table_text = preparer .format_table (insert_stmt .table )
230-
231- if insert_stmt ._hints :
232- dialect_hints = dict ([
233- (table , hint_text )
234- for (table , dialect ), hint_text in
235- insert_stmt ._hints .items ()
236- if dialect in ('*' , self .dialect .name )
237- ])
238- if insert_stmt .table in dialect_hints :
239- table_text = self .format_from_hint_text (
240- table_text ,
241- insert_stmt .table ,
242- dialect_hints [insert_stmt .table ],
243- True
244- )
245-
246- text += table_text
247-
248- if crud_params_single or not supports_default_values :
249- text += " (%s)" % ', ' .join ([preparer .format_column (c [0 ])
250- for c in crud_params_single ])
251-
252- if self .returning or insert_stmt ._returning :
253- self .returning = self .returning or insert_stmt ._returning
254- returning_clause = self .returning_clause (
255- insert_stmt , self .returning )
256-
257- if self .returning_precedes_values :
258- text += " " + returning_clause
259-
260- if insert_stmt .select is not None :
261- text += " (%s)" % self .process (self ._insert_from_select , ** kw )
262- elif not crud_params and supports_default_values :
263- text += " DEFAULT VALUES"
264- elif insert_stmt ._has_multi_parameters :
265- text += " VALUES %s" % (
266- ", " .join (
267- "(%s)" % (
268- ', ' .join (c [1 ] for c in crud_param_set )
269- )
270- for crud_param_set in crud_params
271- )
272- )
273- else :
274- text += " VALUES (%s)" % \
275- ', ' .join ([c [1 ] for c in crud_params ])
276-
277- if self .returning and not self .returning_precedes_values :
278- text += " " + returning_clause
279-
280- self .stack .pop (- 1 )
281-
282- return text
283-
284186 def visit_update (self , update_stmt , ** kw ):
285187 """
286188 used to compile <sql.expression.Update> expressions
0 commit comments