VASmalltalk – SQLite 3.7.2-06

Several tests in the GLORP code delivered with VA 8.02 are simply commented out. Binding stuff for example: object binding and position binding.

After looking at VW and the latest Glorp code there I understand how that should work. Therefore in the newest version of the SQLiteWrapper I had to wrap additional API calls to get the information needed to implement this feature for Glorp. But I build support in my wrapper application and not the the Glorp/SQLite application, because the feature may be also nice to have without Glorp.

The first feature is array based or position binding (but it is rather a variation of named binding):

| bindingArray dbConnection aMSKSQLitePreparedStatement |

aMSKSQLitePreparedStatement
   := dbConnection prepare: 'select * from table where attributeA = :2 
                                                                          and attributeB = :6'.

bindingArray := #( nil 6 nil nil nil 2).
bindingArray mskBindValuesIn: aMSKSQLitePreparedStatement

and this produces a statement ‘select * from table where attrA = 6 and attributeB = 2’.

The next version of binding works with instances of Objects accessors (in the example an instance of association).

| bindingObject dbConnection aMSKSQLitePreparedStatement |

aMSKSQLitePreparedStatement
   := dbConnection prepare: 'select * from table where attributeA = :key 
                                                                  and attributeB = :value'.
bindingObject := 6->2.

bindingObject mskBindValuesIn: aMSKSQLitePreparedStatement

and this produces the same statement as above. The message “key” is sent to the object (and returns 6) and then all parameter named :key are bind to this value and the same happens with “value”. Remove the $: from the parameter name and do a perform …

In this version several smaller bugs have been fixed. Refactoring has been done. Available at vastgoodies …

This entry was posted in Smalltalk and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s