On Sun, Dec 16, 2018 at 10:25:11AM -0800, Todd Blanchard via Pharo-users wrote:
> Metacello new 
>       repository: 'github://pharo-rdbms/glorp-sqlite3';
>       baseline: 'GlorpSQLite';
>       load.

Hi Todd,

Pharo 6 or 7? 32- or 64-bit?

> This seems to be the only way to get SQLite support?  There is no
> standalone UFFI library?  Not that I have a problem with it, I know
> and like GLORP.

GlorpSQLite is built on the standalone SQLite UFFI library. 

> Then I ran the basic UDBCSQLite tests and they all fail with 'External
> module not found'.  I presume this means that the sqlite library was
> not found but the best I can find is a method #library that returns
> #sqlite 
> Reading the well written
> https://files.pharo.org/books-pdfs/booklet-uFFI/UFFIDRAFT.pdf I gather
> that I should subclass FFILibrary to make a SQLiteLibrary and have
> UDBCSQLite class that implements  #macModuleName to return
> '/usr/local/Cellar/libspatialite/4.3.0a_6/libspatialite.dylib'?

The library was written before that convention was established.
Currently it is UDBCSQLite3Library (subclassing Object) and its #library
says this:

  library
    Smalltalk os isMacOS ifTrue: [ ^ #sqlite3 ].
    ^ 'sqlite3'

This worked before as I had used it with Pharo 5 when my Mac was on El
Capitan and Sierra. The Mac is now on High Sierra. 

Testing... Ok, the system-supplied library is named libsqlite3.0.dylib.
After some experimentation, copying/renaming said library works:

  % cp -p /usr/lib/libsqlite3.0.dylib % 
~/Pharo.app/Contents/MacOS/Plugins/libsqlite3.dylib

Now 64-bit Pharo 60543 finds the dylib, the SQLite tests run and pass.
I also tested keeping the '3.0' in the dylib file name, modifying the
#library method accordingly, and evaluating 'UDBCSQLite3Library reset'
to clear the singleton class variable.

I've not run into this situation before because I've always used my own
custom SQLite shared library that includes JSON, FTS etc extensions.

For good measure I also ran the Glorp tests and got 891 run, 890 passes,
1 error. The error is due to my changing SQLite's boolean handling, see 

  https://www.samadhiweb.com/blog/2018.05.20.sqlite.boolean.html

The test error has been fixed for Pharo 7. Not yet back-ported for Pharo
6. 

To load GlorpSQLite for Pharo 7, use the Catalog Browser, or,
equivalently, load from my repo:

  Metacello new 
    repository: 'github://PierceNg/glorp-sqlite3:pharo7';
    baseline: 'GlorpSQLite';
    load.

> spatialite

Cool! Please let me know how this goes. 

Back in Pharo 4's Native Boost days, NBSQLite as it was called then
supported both SQLite and SQLcipher. I had experimented with loading
libsqlcipher3 from UDBCSQLcipher3Library, which subclasses
UDBCSQLite3Library, and IIRC also via some class variable in
UDBCSQLite3Library determining which shared library to load. Torsten
Bergmann kindly ported NBSQLite to UFFI. The SQLcipher part is still on
my to-do list, and I am also interested to have (Glorp|UDBC)SQLite load
Spatialite (and maybe even libspatialitecipher) cleanly.

Pierce


Reply via email to