Dear all,
I'm working on ADO database driver for Glorp by using Pablo's PharoCOM. The structure of the driver is similar to Sven's P3DatabaseDriver and P3Client (thanks, Sven for very clear architecture :-) ) and the work is progressing quite nicely. I can connect to SQL Server, PostgreSQL and create tables, insert and read data directly with ADO Connection and Recordset objects, and with Glorp, too. In next days I'll do some more testing, including Oracle, and publish the prototype on GitHub. The goal is not PostgreSQL, of course, but to finally reach SQL Server, Oracle and possibly MS Access, at least from Windows systems. One thing is bothering me though - SQL Server supports Unicode with NCHAR and NVARCHAR types, and when using INSERT INTO with literal strings these should be prefixed with N, like in N'This is a Unicode string' Does somebody remember whether Glorp can prefix the strings in that way when constructing SQL statements? I checked all the constants and string conversions under DatabasePlatform but haven't found anything related to this kind of prefixing. Thanks and best wishes, Tomaz -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html |
Hi Tomaz,
> On 11 Oct 2019, at 18:15, eftomi <[hidden email]> wrote: > > Dear all, > > I'm working on ADO database driver for Glorp by using Pablo's PharoCOM. The > structure of the driver is similar to Sven's P3DatabaseDriver and P3Client > (thanks, Sven for very clear architecture :-) ) and the work is progressing > quite nicely. I can connect to SQL Server, PostgreSQL and create tables, > insert and read data directly with ADO Connection and Recordset objects, and > with Glorp, too. In next days I'll do some more testing, including Oracle, > and publish the prototype on GitHub. The goal is not PostgreSQL, of course, > but to finally reach SQL Server, Oracle and possibly MS Access, at least > from Windows systems. Great to hear this, please keep us all posted of your progress. > One thing is bothering me though - SQL Server supports Unicode with NCHAR > and NVARCHAR types, and when using INSERT INTO with literal strings these > should be prefixed with N, like in > > N'This is a Unicode string' > > Does somebody remember whether Glorp can prefix the strings in that way when > constructing SQL statements? I checked all the constants and string > conversions under DatabasePlatform but haven't found anything related to > this kind of prefixing. I don't know for sure. Could you not add the N at the moment the string quotes are written ? What I do know is this: the interface between P3DatabaseDriver and P3Client is essentially an SQL string to execute. That SQL string was built by the Glorp machinery, so it must know about certain specifics (like string quoting and escaping, etc). Also, in Glorp's Login #database specification, a platform is set, like PostgreSQLPlatform. So I am assuming some platform specific delegation is happening (or could happen). I don't have a Glorp image ready, but there must be a way to find this out. That being said, I do foresee a problem for you. You are building a more general driver that can access several different platforms, you will need to make that explicit, else you won't be able to do something specific for SQL Server. HTH, Sven > Thanks and best wishes, > Tomaz > > > > -- > Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html > |
Thanks, Sven. I found the "ultimate" place where strings are being prepared
for INSERT INTO clause - this happens in String>>#glorpPrintSQLOn:. Not so easy to parametrize at a first glance. Maybe with WideString>>#glorpPrintSQLOn: but I'm not sure how other platforms would be happy. I decided to work on other issues right now so that I can publish a relatively decent package ASAP. An interesting observation about UTF-8 and SQL Server 2019 is here: https://sqlquantumleap.com/2018/09/28/native-utf-8-support-in-sql-server-2019-savior-false-prophet-or-both/. Best wishes, Tomaz -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html |
Hello Tomaz. I am the author of that UTF-8 in SQL Server 2019 post you linked to, and I think I can provide some context here.
Take care, Solomon...
_____________________________________________________________
_____________________________________________________________
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
_____________________________________________________________
_____________________________________________________________
|
Solomon, thank you for your additional insights. Of course we'll have to wait
for SQL Server 2019 to be adopted - tactful devops wait for SP2 of v4 to change from v2 to v3 :-) Indeed I solved the problem in NVARCHAR / NCHAR / NTEXT by adding the method WideString>>#glorpPrintSQLOn: which is almost the same as String>>#glorpPrintSQLOn: except that it checks whether the database platform understands a message #prefixForUnicode. Then I subclassed SQLServerPlatform as #SQLServerPlatformN with this constant which returns $N. To use this, one has to: - define the field type in DescriptorSystem as 'platform nvarchar width: xx' (or nchar, ntext) - set the platform to SQLServerPlatformN (N for 'National Language Character Set'). For now, I subclassed SQLServerPlatform if there will be any other additions to SQL Server Glorp platform. In the future the constant should probably become just an "ordinary" extension to Glorp's SQLServerPlatform. These changes are now available at https://github.com/eftomi/pharo-ado. Best wishes, Tomaz -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html |
Free forum by Nabble | Edit this page |