[PATCH] Resurrect Glorp

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Resurrect Glorp

Paolo Bonzini
Ditto.  The tests take too much for putting them into 'make check'.
Maybe later.

Found out that #isBits had been deleted by mistake.

Paolo

* looking for [hidden email]--2004b/smalltalk--devo--2.2--patch-521 to compare with
* comparing to [hidden email]--2004b/smalltalk--devo--2.2--patch-521
M  packages/glorp/package.xml
M  packages/glorp/Glorp.st
M  packages/glorp/GlorpMySQL.st
M  packages/glorp/GlorpPort.st
M  packages/glorp/GlorpTest.st
M  packages/mysql/MySQL.st
M  kernel/Behavior.st

* modified files

--- orig/kernel/Behavior.st
+++ mod/kernel/Behavior.st
@@ -829,6 +829,10 @@ scopeHas: name ifTrue: aBlock
 
 !Behavior methodsFor: 'testing the form of the instances'!
 
+isBits
+    ^self shape notNil and: [ self isPointers not ]
+!
+
 isPointers
     "Answer whether the instance variables of the receiver's instances
      are objects"


--- orig/packages/glorp/Glorp.st
+++ mod/packages/glorp/Glorp.st
@@ -1,5 +1,3 @@
-Namespace current: Smalltalk!
-
 Smalltalk.Object subclass: #GlorpHelper
     instanceVariableNames: ''
     classVariableNames: ''
@@ -20,10 +18,6 @@ Instance Variables:
 
 '!
 
-
-Smalltalk addSubspace: #Glorp!
-Namespace current: Glorp!
-
 Smalltalk.Object subclass: #CachePolicy
     instanceVariableNames: 'expiryAction numberOfElements '
     classVariableNames: ''
@@ -11353,11 +11347,6 @@ atIndex: anInteger
     "For compatibility with Dolphin and VA data base rows."
     ^self at: anInteger.! !
 
-!Smalltalk.Collection methodsFor: 'streams'!
-
-writeStream
-    ^AddingWriteStream on: self.! !
-
 !Smalltalk.Time methodsFor: 'printing'!
 
 glorpPadToTwoDigits: anInteger
@@ -11426,7 +11415,7 @@ needsWork: aString
 todo
     "marker"! !
 
-!Smalltalk.GlorpHelper methodsFor: 'glorp'!
+!GlorpHelper class methodsFor: 'glorp'!
 
 glorpBaseExpressionClass
     "This is to work around Dolphin's obnoxious insistence on absolute prerequisite enforcement. We have to define extension methods on blocks for asGlorpExpression. These need to create a messageArchiver. Those have to be in the dialect-specific prereq, but since that gets loaded before anything else it can't reference Glorp classes. So have it send a message instead"
@@ -11476,14 +11465,14 @@ glorpIsCollection
 
 glorpPrintSQLOn: aStream
     aStream nextPut: $(.
-    GlorpHelper  do: [:each | each glorpPrintSQLOn: aStream]
+    Glorp.GlorpHelper  do: [:each | each glorpPrintSQLOn: aStream]
      for: self
      separatedBy: [aStream nextPutAll: ', '].
     aStream nextPut: $)!
 
 glorpPrintSQLOn: aStream for: aType
     aStream nextPut: $(.
-    GlorpHelper
+    Glorp.GlorpHelper
      do: [:each | aType print: each on: aStream]
      for: self
      separatedBy: [aStream nextPutAll: ', '].
@@ -11500,5 +11489,3 @@ glorpRegisterCollectionInternalsIn: anOb
      ifFalse: [anObjectTransaction register: (self instVarAt: index)]]! !
 
 Glorp.FunctionExpression initialize!
-
-Namespace current: Smalltalk!


--- orig/packages/glorp/GlorpMySQL.st
+++ mod/packages/glorp/GlorpMySQL.st
@@ -1,8 +1,6 @@
 'From VisualWorks®, Pre-Release 7 of June 3, 2002 on August 23, 2002 at 9:50:56 pm'!
 "Package GlorpDatabase(0.2.11,aknight)="!
 
-Namespace current: Glorp!
-
 DatabasePlatform subclass: #MySQLPlatform
     instanceVariableNames: ''
     classVariableNames: 'NewTableType'
@@ -141,6 +139,10 @@ dropConstraint: aConstraint
 dropTableNamed: aString
     self executeSQLString: 'DROP TABLE IF EXISTS ' , aString!
 
+dropTableNamed: aString ifAbsent: aBlock
+    self doCommand: [self executeSQLString: 'DROP TABLE ' , aString]
+        ifError: aBlock!
+
 executeSQLString: aString
     | statement result resultSet rows row numColumns |
     statement := connection createStatement.
@@ -256,8 +258,8 @@ printTimestamp: aTimestamp for: aType
 
 convertBooleanToDBBoolean: aBoolean for: aType
     aBoolean isNil ifTrue: [^nil].
-    aBoolean isInteger ifTrue: [ ^aBoolean ].
-    ^aBoolean ifTrue: [1] ifFalse: [0]!
+    aBoolean isInteger ifTrue: [ ^aBoolean ~= 0].
+    ^aBoolean!
 
 convertDBBooleanToBoolean: aBoolean for: aType
     aBoolean isInteger ifFalse: [^aBoolean].


--- orig/packages/glorp/GlorpPort.st
+++ mod/packages/glorp/GlorpPort.st
@@ -1,6 +1,3 @@
-Smalltalk addSubspace: #Glorp!
-Namespace current: Glorp!
-
 nil subclass: #ProtoObject
     instanceVariableNames: ''
     classVariableNames: ''
@@ -64,16 +61,16 @@ isBlock
 !BlockClosure methodsFor: 'glorp'!
 
 asGlorpExpression
-    ^self asGlorpExpressionOn: GlorpHelper glorpBaseExpressionClass new.!
+    ^self asGlorpExpressionOn: Glorp.GlorpHelper glorpBaseExpressionClass new.!
 
 asGlorpExpressionForDescriptor: aDescriptor
     | base |
-    base := GlorpHelper glorpBaseExpressionClass new.
+    base := Glorp.GlorpHelper glorpBaseExpressionClass new.
     base descriptor: aDescriptor.
     ^self asGlorpExpressionOn: base.!
 
 asGlorpExpressionOn: anExpression
-    ^(self value: GlorpHelper glorpMessageArchiverClass new) asGlorpExpressionOn: anExpression!
+    ^(self value: Glorp.GlorpHelper glorpMessageArchiverClass new) asGlorpExpressionOn: anExpression!
 
 isBlock
     ^true! !
@@ -118,3 +115,14 @@ glorpPrintSQLOn: stream
         next: (self second < 10 ifTrue: [ 1 ] ifFalse: [ 0 ]) put: $0;
         print: self second;
         nextPut: $'! !
+!Smalltalk.OrderedCollection methodsFor: 'testing'!
+
+writeStream
+    "For our purposes, these aren't collections, but rather a simple database type"
+    ^Glorp.AddingWriteStream on: self.! !
+
+!Smalltalk.Collection methodsFor: 'streams'!
+
+writeStream
+    ^Glorp.AddingWriteStream on: self.! !
+


--- orig/packages/glorp/GlorpTest.st
+++ mod/packages/glorp/GlorpTest.st
@@ -1,5 +1,4 @@
 Smalltalk addSubspace: #GlorpTestNamespace!
-Namespace current: Glorp!
 
 TestCase subclass: #GlorpTestCase
     instanceVariableNames: ''
@@ -2224,8 +2223,8 @@ defaultMysqlLogin
 
     ^(Login new)
      database: MySQLPlatform new;
-     username: '';
-     password: '';
+     username: 'root';
+     password: 'root';
      connectString: 'test'.! !
 
 !GlorpDatabaseLoginResource class methodsFor: 'LICENSE'!
@@ -7014,10 +7013,12 @@ helpTestValue: anObject
     self helpTestValue: anObject
  compareModelWith: [:read :original |
     read notNil and: [
-        (original class isKindOf: Float)
+        (original isKindOf: Float)
             or: [ original class == Dialect doublePrecisionFloatClass
     or: [ read test = original ]]]]
- compareWith: [:read :original | read = original].!
+ compareWith: [:read :original |
+        (original isKindOf: Float)
+    or: [ read = original ] ].!
 
 helpTestValue: anObject compareWith: aBlock
     self
@@ -8004,6 +8005,9 @@ testCreateTable
     | selectResult |
     [[self accessor beginTransaction.
     self accessor
+     dropTableNamed: 'GLORP_TEST_CREATE'
+     ifAbsent: [:ex | ex return: nil].
+    self accessor
      executeSQLString: 'CREATE TABLE GLORP_TEST_CREATE (ID varchar(4))']
      ensure: [self accessor commitTransaction].
     selectResult := self accessor
@@ -10726,5 +10730,3 @@ resources
 
 unfinished
     "indicates an unfinished test"! !
-
-Namespace current: Smalltalk!


--- orig/packages/glorp/package.xml
+++ mod/packages/glorp/package.xml
@@ -2,10 +2,17 @@
   <name>Glorp</name>
   <prereq>MySQL</prereq>
   <prereq>SUnit</prereq>
+
+  <namespace>Glorp</namespace>
+
   <filein>GlorpPort.st</filein>
   <filein>Glorp.st</filein>
   <filein>GlorpMySQL.st</filein>
-  <filein>GlorpTest.st</filein>
+
+  <test>
+    <sunit>Glorp.GlorpTestCase*</sunit>
+    <filein>GlorpTest.st</filein>
+  </test>
 
   <file>GlorpPort.st</file>
   <file>Glorp.st</file>


--- orig/packages/mysql/MySQL.st
+++ mod/packages/mysql/MySQL.st
@@ -868,10 +868,8 @@ on: aConnection
 !JdmServerVersion methodsFor: 'reading'!
 
 readFrom: aStream
- fileFormat := Integer readFrom: aStream.
- aStream next.
- release := Integer readFrom: aStream.
- aStream next.
+ fileFormat := aStream upTo: $..
+ release := aStream upTo: $..
  version := Integer readFrom: aStream.
 ! !
 
@@ -1076,17 +1074,23 @@ JdmColumn class
 
 !JdmColumn class methodsFor: 'constants-types'!
 
+bitType
+ ^16!
+
 blobType
  ^252!
 
 datetimeType
  ^12!
 
+newDateType
+ ^14!
+
 dateType
  ^10!
 
 oldDecimalType
- ^246!
+ ^0!
 
 decimalType
  ^246!
@@ -1142,6 +1146,9 @@ tinyBlobType
 tinyType
  ^1!
 
+varCharType
+ ^15!
+
 varStringType
  ^253!
 
@@ -1266,6 +1273,11 @@ withNumColumns: anInteger
 
 !JdmFieldConverter methodsFor: 'converting-smalltalk'!
 
+writeBoolean: aBoolean on: aStream
+ aBoolean
+ ifTrue: [ aStream nextPutAll: 'True' ]
+ ifFalse: [ aStream nextPutAll: 'False' ]!
+
 writeDate: aDate on: aStream
  JdmTimestampWriter printMysqlDate: aDate on: aStream!
 
@@ -1351,6 +1363,10 @@ convertToMysql: aValue on: aStream
 
 !JdmFieldConverter methodsFor: 'converting'!
 
+toBoolean: aString column: aColumn
+ aString isNil ifTrue: [ ^nil ].
+ ^aString first value = 1!
+
 toByteArray: aString column: aColumn
  ^aColumn isBinary
  ifTrue: [aString isNil
@@ -1409,6 +1425,7 @@ toTimestamp: aString column: aColumn
 buildConversionMap
  converterSelectors := IdentityDictionary new.
  converterSelectors
+ at: #Boolean put: #writeBoolean:on:;
  at: #FloatD put: #writeDouble:on:;
  at: #FloatE put: #writeFloat:on:;
  at: #Time put: #writeQuotedTime:on:;
@@ -1419,6 +1436,7 @@ buildConversionMap
 buildTypeMap
  types := Dictionary new.
  types
+ at: JdmColumn bitType put: #toBoolean:column:;
  at: JdmColumn tinyType put: #toInteger:column:;
  at: JdmColumn shortType put: #toInteger:column:;
  at: JdmColumn longType put: #toInteger:column:;
@@ -1428,6 +1446,7 @@ buildTypeMap
  at: JdmColumn doubleType put: #toDouble:column:;
  at: JdmColumn oldDecimalType put: #toDouble:column:;
  at: JdmColumn decimalType put: #toDouble:column:;
+ at: JdmColumn newDateType put: #toDate:column:;
  at: JdmColumn dateType put: #toDate:column:;
  at: JdmColumn datetimeType put: #toDateTime:column:;
  at: JdmColumn timeType put: #toTime:column:;
@@ -1438,6 +1457,7 @@ buildTypeMap
  at: JdmColumn mediumBlobType put: #toByteArray:column:;
  at: JdmColumn longBlobType put: #toByteArray:column:;
  at: JdmColumn blobType put: #toByteArray:column:;
+ at: JdmColumn varCharType put: #toString:column:;
  at: JdmColumn varStringType put: #toString:column:;
  at: JdmColumn stringType put: #toString:column:! !
 




_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk