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

typename argument in Cursor.var() #231

Open
doerwalter opened this Issue Oct 23, 2018 · 6 comments

Comments

Projects
None yet
2 participants
@doerwalter
Copy link

doerwalter commented Oct 23, 2018

I would like to be able to pass a value None for the typename argument of Cursor.var(). However cx_Oracle raises the following exception in this case:

DatabaseError: DPI-1046: parameter name cannot be a NULL pointer

I would have expected this to behave exactly like when typename wasn't passed at all.

This means that currenly I have to do the following:

if typename is None:
    var = cursor.var(t)
else:
    var = cursor.var(t, typename=typename)

which is inelegant.

@doerwalter

This comment has been minimized.

Copy link
Author

doerwalter commented Oct 23, 2018

It would be even better if I could pass the cx_Oracle object type as the type argument to Cursor.var(), i.e. something that Connection.gettype() returns.

@anthony-tuininga

This comment has been minimized.

Copy link
Member

anthony-tuininga commented Oct 29, 2018

Thanks @doerwalter. I agree that None should be allowable for the typename argument, and that the object returned from Connection.gettype() should be allowed to be passed to the dataType parameter of Cursor.var(). I'll address these both and let you know when they have been done.

anthony-tuininga added a commit that referenced this issue Oct 30, 2018

Add support for passing an object type (such as those created by the …
…method

connection.gettype()) as the first parameter to cursor.var(), as requested
(#231).
@anthony-tuininga

This comment has been minimized.

Copy link
Member

anthony-tuininga commented Oct 30, 2018

@doerwalter, I have just pushed changes that address both of these issues. Can you give them a whirl and let me know if the changes address your requests? Thanks!

@doerwalter

This comment has been minimized.

Copy link
Author

doerwalter commented Oct 31, 2018

Both changes work indead as expected. Thanks for implementing those. With this change I can then simply use

arg.type if isinstance(arg, cx_Oracle.Object) else type(arg)

as the cursor type for passing the argument var.

But this leads to an even simpler solution (at least from the standpoint of the user ;)). Maybe what Connection.gettype() returns should be a real Python type, then the value could be an instance of that type. I.e. Connection.gettype() would return a subclass of cx_Oracle.Object and the value would be an instance of that subclass. Then the variable type would simply be type(arg) in all cases and cx_Oracle.ObjectType would be unneccessary. Conceptually this would be much simpler, because then types and instances would be much closer to how they work in Python. However I don't know whether that's feasable to implement.

@anthony-tuininga

This comment has been minimized.

Copy link
Member

anthony-tuininga commented Oct 31, 2018

That's an interesting concept, which I considered briefly at one point. :-) I'll give it some more thought as I agree that it would simplify matters considerably and I believe it is indeed feasible to implement. I'll get back to you on that.

@anthony-tuininga

This comment has been minimized.

Copy link
Member

anthony-tuininga commented Feb 5, 2019

The initial request was implemented in cx_Oracle 7.1 which was released yesterday. I still haven't looked into your other suggestion so I'll leave this open until I do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment