-
Notifications
You must be signed in to change notification settings - Fork 309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pymssql 2.x does not support "%(foo)d" parameter substitution style; pymssql 1.x did #155
Comments
pymssql advertises that it supports only the pyformat paramstyle. In pymssql.pyx, it has this line: paramstyle = 'pyformat' But perhaps this should be mentioned in the new docs from @ramiro if it's not already there. It sounds like you also might've found a problem with the pyformat stuff relating to '%(foo)d"? Is it the d (integer) specifically? The two lines you posted look identical; maybe a copy/paste error? Maybe the failing one should be d instead of s? |
Looking at the code some more, I can see that pymssql advertises that it supports pyformat as I mentioned. However it also supports format (looking at the code for the The tricky thing about pyformat is that if you look at PEP 249, the only example they show for pyformat is %(foo)s -- e.g.: with the s. It's not clear whether they meant that other things like d, f, or i are supported. I found this thread where someone asked about this and it seemed the general consensus was that only the s form was required. This includes Marc-André Lemburg, who authored PEP 249. It seems that pymssql 1.X supported those extra forms though, whereas pymssql 2.X does not. I see 3 options:
Let me know if you have other thoughts. |
On 1/8/14, 1:38 AM, Marc Abramowitz wrote:
Randy Syring /"For what does it profit a man to gain the whole world |
Just fixed the typo in the comment 1. cur.execute('select @@version where 1=%(name)d', dict(name=1)) # fail |
I prefer 3, we keep the backward compatibility as pymssql 1.x, that would make the migration much easier. |
Just changed the title from:
to:
|
@kunxi but a major release is the place to break BC if we are going to break it. Marc, I think this one is up to you since you are currently working on the code. From an idealist perspective, supporting the differing characters "%s, %d" implies some kind of different handling based on type, IMO. It seems best to avoid that. At the same time, it's not likely to cause much headache in practice, so.... |
@rsyring: @kunxi and I work together and we spoke about this yesterday and he seems OK with changing his code to use a different paramstyle, as the So I'm closing this. @kunxi: If you run into problems and you have to have this, let me know and we can reopen. |
Oh, I forgot to mention, that I added info about this to the docs: http://pymssql.org/migrate_1_x_to_2_x.html#parameter-substitution |
Just for the record: the above URL now is: |
The PEP 249 support various params binding.
qmark is not supported:
numeric is not supported:
named is not supported:
format is partially supported:
pyformat does not support %(foo)d:
The text was updated successfully, but these errors were encountered: