Skip to content

compilers that apply binds in select precolumns can be out of sync with column-nested subqueries #3038

Closed
@sqlalchemy-bot

Description

@sqlalchemy-bot
Collaborator

Migrated issue, originally created by Michael Bayer (@zzzeek)

e.g. firebird, sql server, others:

from sqlalchemy import *
from sqlalchemy.sql import column, literal

s1 = select([column('x')]).select_from('a').limit(5).as_scalar()
s2 = select([s1]).limit(10)

from sqlalchemy.engine import default
from sqlalchemy.sql import compiler
class MyCompiler(compiler.SQLCompiler):
    def get_select_precolumns(self, select):
        result = ""
        if select._limit:
            result += "FIRST %s " % self.process(literal(select._limit))
        if select._offset:
            result += "SKIP %s " % self.process(literal(select._offset))
        return result

    def limit_clause(self, select):
        return ""


dialect = default.DefaultDialect()
dialect.statement_compiler = MyCompiler
dialect.paramstyle = 'qmark'
dialect.positional = True
compiled = s2.compile(dialect=dialect)
assert \
  [compiled.params[name] for name in compiled.positiontup] == [10, 5]

Activity

sqlalchemy-bot

sqlalchemy-bot commented on Apr 30, 2014

@sqlalchemy-bot
CollaboratorAuthor

Michael Bayer (@zzzeek) wrote:

5da667e

sqlalchemy-bot

sqlalchemy-bot commented on Apr 30, 2014

@sqlalchemy-bot
CollaboratorAuthor

Michael Bayer (@zzzeek) wrote:

2a45868

sqlalchemy-bot

sqlalchemy-bot commented on Apr 30, 2014

@sqlalchemy-bot
CollaboratorAuthor

Changes by Michael Bayer (@zzzeek):

  • changed status to closed
sqlalchemy-bot

sqlalchemy-bot commented on Sep 27, 2017

@sqlalchemy-bot
CollaboratorAuthor

Michael Bayer (@zzzeek) wrote:

5da667e

added this to the 0.9.5 milestone on Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @sqlalchemy-bot

        Issue actions

          compilers that apply binds in select precolumns can be out of sync with column-nested subqueries · Issue #3038 · sqlalchemy/sqlalchemy