예제 #1
0
    def __handle_regular_columns(self, stmt, parameters, set_clauses):
        need_pks = self.isinsert and \
            not self.inline and \
            not stmt._returning

        implicit_returning = need_pks and \
            self.dialect.implicit_returning and \
            stmt.table.implicit_returning

        for c in stmt.table.columns:
            if c.key in parameters:
                value = parameters.pop(c.key)
                if sa_is_literal(value):
                    value = self._create_crud_bind_param(
                        c,
                        value,
                        required=value is sa.sql.compiler.REQUIRED,
                        name=c.key)
                elif c.primary_key and implicit_returning:
                    self.returning.append(c)
                    value = self.process(value.self_group())
                else:
                    self.postfetch.append(c)
                    value = self.process(value.self_group())
                clause = c._compiler_dispatch(self,
                                              include_table=False) + ' = ?'
                set_clauses.append(clause)
            elif self.isupdate:
                if (c.onupdate is not None and not c.onupdate.is_sequence
                        and not c.onupdate.is_clause_element):
                    set_clauses.append('{0} = {1}'.format(
                        c._compiler_dispatch(self, include_table=False),
                        self._create_crud_bind_param(c, None)))
                    self.prefetch.append(c)
예제 #2
0
    def __handle_regular_columns(self, stmt, parameters, set_clauses):
        need_pks = self.isinsert and \
            not self.inline and \
            not stmt._returning

        implicit_returning = need_pks and \
            self.dialect.implicit_returning and \
            stmt.table.implicit_returning

        for c in stmt.table.columns:
            if c.key in parameters:
                value = parameters.pop(c.key)
                if sa_is_literal(value):
                    value = self._create_crud_bind_param(
                        c, value, required=value is sa.sql.compiler.REQUIRED,
                        name=c.key
                    )
                elif c.primary_key and implicit_returning:
                    self.returning.append(c)
                    value = self.process(value.self_group())
                else:
                    self.postfetch.append(c)
                    value = self.process(value.self_group())
                set_clauses.append(c._compiler_dispatch(self, include_table=False) + ' = ?')
            elif self.isupdate:
                if (
                    c.onupdate is not None
                    and not c.onupdate.is_sequence
                    and not c.onupdate.is_clause_element
                ):
                    set_clauses.append('{0} = {1}'.format(
                        c._compiler_dispatch(self, include_table=False),
                        self._create_crud_bind_param(c, None)
                    ))
                    self.prefetch.append(c)
예제 #3
0
    def __handle_regular_columns(self, stmt, parameters, set_clauses):
        need_pks = self.isinsert and \
            not self.inline and \
            not stmt._returning

        implicit_returning = need_pks and \
            self.dialect.implicit_returning and \
            stmt.table.implicit_returning

        for c in stmt.table.columns:
            if c.key in parameters:
                value = parameters.pop(c.key)
                if sa_is_literal(value):
                    value = self._create_crud_bind_param(
                        c, value, required=value is sa.sql.compiler.REQUIRED,
                        name=c.key
                    )
                elif c.primary_key and implicit_returning:
                    self.returning.append(c)
                    value = self.process(value.self_group())
                else:
                    self.postfetch.append(c)
                    value = self.process(value.self_group())
                set_clauses.append(c._compiler_dispatch(self) + ' = ?')