Giter VIP home page Giter VIP logo

Comments (4)

julioalpa avatar julioalpa commented on June 12, 2024

Hi, i have the same problem.

Could you resolve this issue?
How??

Best Regards,
Julio Sánchez.

from django-pyodbc.

rbalch avatar rbalch commented on June 12, 2024

I did finally resolve it, but after a year or so I'm having trouble remembering. Over the last few years I've actually made a few little patches to pyodbc that made it work better with django. Looking through git logs I think I made a simple patch to the pyodbc/compiler.py file.

In the file there's a function "as_sql", and in there I swapped out:

    if self.return_id and self.connection.features.can_return_id_from_insert:
        params = params[0]
        output = 'OUTPUT inserted.%s' % qn(opts.pk.column)
        result.append(output)
        result.append("VALUES (%s)" % ", ".join(placeholders[0]))
        return [(" ".join(result), tuple(params))]

with:

    if self.return_id and self.connection.features.can_return_id_from_insert:
        params = params[0]
        #TODO: ryan commented out old output method and replace with scope_identity
        # output = 'OUTPUT inserted.%s' % qn(opts.pk.column)
        # result.append(output)
        result.append("VALUES (%s)" % ", ".join(placeholders[0]))
        result.append("SELECT SCOPE_IDENTITY()")
        return [(" ".join(result), tuple(params))]

... let me know if that doesn't work and i'll dig into it a bit more

from django-pyodbc.

julioalpa avatar julioalpa commented on June 12, 2024

Thanks eviltandem for your support!!

mmmm but this code is just under where i get the error code..

result.append('INSERT INTO %s' % qn(opts.db_table))
result.append('(%s)' % ', '.join([qn(c) for c in self.query.columns])) # <=== here is the error

if self.return_id and self.connection.features.can_return_id_from_insert:
params = params[0]
#TODO: ryan commented out old output method and replace with scope_identity
# output = 'OUTPUT inserted.%s' % qn(opts.pk.column)
# result.append(output)
result.append("VALUES (%s)" % ", ".join(placeholders[0]))
result.append("SELECT SCOPE_IDENTITY()")
return [(" ".join(result), tuple(params))]

Can you give me the columns part? Or maybe all the compile.py

BR,
Julio Sánchez.

from django-pyodbc.

julioalpa avatar julioalpa commented on June 12, 2024

Done!, I was replace all the as_sql code to the as_code from Github lastest version.

It Works!!

Thanks a lot eviltandem!!

Best Regards,
Julio Sánchez.

from django-pyodbc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.