[Seaside] ROE - Public Store

Brett Taylor brett.taylor at healthauditors.com
Wed Mar 31 18:48:54 CEST 2004


Danil & Avi,
I think it would be great to get rid of the Squeak specific code in the
base as you have done.  Did you implement support for other databases? 
In order to support Oracle, I factored out an Abstract class like your
RARealRelation. I called it RADatabaseRelation. This allows the
resolution of some problems - but I also found there were issues I
couldn't resolve in this manner.
1) Different SQL Syntax:
	* Aliasing column names and table names is different between Oracle &
Postgres
	* No support for the LIMIT operator in Oracle
	* Postgres EXCEPT operator is MINUS in Oracle
2) Attribute to Colummn name mapping fails in Oracle
 Oracle uses cases insensitive names by default.  This causes
#resolveAttributeIn: aCollection to fail and
RARelation>>attributeNamed:ifAbsent: to fail.   

I resolved these problems by adding a couple of classes.  First of all -
I created a class called the SqlDialect with subclasses OracleDialect &
PostgresDialect.  These classes handle dialect specific name resolution
(through double dispatching) and determining which Printer class to use
for generating SQL code.  I also created a new SQL printer class
RAOracleSqlPrinter which handles the differences in SQL code between the
dialects.  

There are other capabilities that are Database Driver specific such as
the ability to use bind variables and bind arrays.   Support for these
can probably also be divided between the Relation, Dialect, and Printer.
What do you think?

Brett Taylor
On Tue, 2004-03-30 at 23:20, danil osipchuk wrote:
> Hello, Brent and Avi
> 
> > In the latest version on Store, I've added support for the Oracle
> > database.  This required a bit of refactoring so I've branched on
> > versions.  I'll submit the changes to Avi to see if he wants integrate
> > them into the main stream.
> > 
> > Brett Taylor
> 
> I browsed your code in public store, and found your changes pretty 
> suitable for me, so for me there is no much difference which one Avi 
> will choose to include (if he wants).
> Basically there are next incompatibilities:
> 1){} brackets in tests (the single obvious solution)
> 2) symbols and string in tests (all reduced to strings)
> 3) RASqlPrinter  & RASqlSingleTabler #printerOperator: monsters  - the 
> code is fine for squeak, but definitely not portable. My solution is:
> (for eliminating double code)
> 

> RANode>>sqlOperator
> 
> 	"other ways are: dynamic dictionary construction (as you did) and class 
> var with dictionary."
> 	
> 	(operator = #&) ifTrue: [^' AND '].
> 	(operator = #|)  ifTrue: [^' OR '].	
>      (operator = #~=) ifTrue: [^' != '].
> 	(operator = #like) ifTrue: [^' LIKE '].
> 	(operator = #ilike) ifTrue: [^' ILIKE '].
> 	
> 	^operator
> 
Yeah - I wasn't so happy with my solution. The dictionary didn't buy
anything.
> and redefine:
> RASqlPrinter>>printOperator: aNode
> 	stream nextPutAll: aNode sqlOperator
> 
> RAPrinter>>printOperator: aNode
> 	stream nextPutAll: aNode operator
> 
> RASingleTableSqlPrinter>>printOperator: aNode
> 	stream nextPutAll: aNode sqlOperator
> (I'm probably again violating some conventions about what should be 
> passed to what, but idea is clear)
> 
> 4) unified resolution of strings and symbols. I forced it in:
> String>>resolveAttributeIn: aCollection
> 	^ aCollection
> 		detect: [:ea | ea name asString = self]
> 		ifNone: [self errorCouldNotResolveAttribute]
> Symbol>>resolveAttributeIn: aCollection
> 	^ aCollection
> 		detect: [:ea | ea name asSymbol = self]
> 		ifNone: [self errorCouldNotResolveAttribute]
> 
> RARelation>>attributeNamed: aString ifAbsent: errorBlock
> ...snipped...
> 		[:ea |
> 		ea name asString = aString asString ifTrue:
> ...snipped...
This looks good - but see above for my problem with case insensitive
lookups.
> 5) Finally, I'm created abstract RARealRelation for databases and pushed 
> common functionality there. I also splitted #execute: into #exec: (no 
> result queries) and #query: (queries returning values).
> 
This makes sense.
> 
> All this now can be filled in dolphin with some compatibility methods 
> which are basically the same for dolphin and VW
> 
> ______________________________________________________________________
> _______________________________________________
> Seaside mailing list
> Seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/listinfo/seaside



More information about the Seaside mailing list