]> gitweb.factorcode.org Git - factor.git/commitdiff
fix url objects, use new accessors more in db.tuples-tests
authorDoug Coleman <doug.coleman@gmail.com>
Thu, 12 Jun 2008 23:20:15 +0000 (18:20 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Thu, 12 Jun 2008 23:20:15 +0000 (18:20 -0500)
extra/db/postgresql/postgresql.factor
extra/db/tuples/tuples-tests.factor

index 1734fb6df4b15b41bf5b39b4bff782028a942eae..e57efbc360b38c42034b1e871e5beeb409d99113 100755 (executable)
@@ -239,7 +239,7 @@ M: postgresql-db persistent-table ( -- hashtable )
         { TIMESTAMP { "timestamp" "timestamp" f } }
         { BLOB { "bytea" "bytea" f } }
         { FACTOR-BLOB { "bytea" "bytea" f } }
-        { URL { "string" "string" f } }
+        { URL { "varchar" "varchar" f } }
         { +foreign-id+ { f f "references" } }
         { +autoincrement+ { f f "autoincrement" } }
         { +unique+ { f f "unique" } }
index 7ccee7c6373dc7a9903795dce6821cdcef96c6aa..b5b80355fe8efe07392f4fa9aa7dcc0b517121c9 100755 (executable)
@@ -8,22 +8,23 @@ math.ranges strings sequences.lib ;
 IN: db.tuples.tests
 
 TUPLE: person the-id the-name the-number the-real
-ts date time blob factor-blob ;
-
-: <person> ( name age real ts date time blob factor-blob -- person )
-    {
-        set-person-the-name
-        set-person-the-number
-        set-person-the-real
-        set-person-ts
-        set-person-date
-        set-person-time
-        set-person-blob
-        set-person-factor-blob
-    } person construct ;
-
-: <user-assigned-person> ( id name age real ts date time blob factor-blob -- person )
-    <person> [ set-person-the-id ] keep ;
+ts date time blob factor-blob url ;
+
+: <person> ( name age real ts date time blob factor-blob url -- person )
+    person new
+        swap >>url
+        swap >>factor-blob
+        swap >>blob
+        swap >>time
+        swap >>date
+        swap >>ts
+        swap >>the-real
+        swap >>the-number
+        swap >>the-name ;
+
+: <user-assigned-person> ( id name age real ts date time blob factor-blob url -- person )
+    <person>
+        swap >>the-id ;
 
 SYMBOL: person1
 SYMBOL: person2
@@ -120,19 +121,20 @@ SYMBOL: person4
         { "time" "T" TIME }
         { "blob" "B" BLOB }
         { "factor-blob" "FB" FACTOR-BLOB }
+        { "url" "U" URL }
     } define-persistent
-    "billy" 10 3.14 f f f f f <person> person1 set
-    "johnny" 10 3.14 f f f f f <person> person2 set
+    "billy" 10 3.14 f f f f f <person> person1 set
+    "johnny" 10 3.14 f f f f f <person> person2 set
     "teddy" 10 3.14
         T{ timestamp f 2008 3 5 16 24 11 T{ duration f 0 0 0 0 0 0 } }
         T{ timestamp f 2008 11 22 0 0 0 T{ duration f 0 0 0 0 0 0 } }
         T{ timestamp f f f f 12 34 56 T{ duration f 0 0 0 0 0 0 } }
-        B{ 115 116 111 114 101 105 110 97 98 108 111 98 } f <person> person3 set
+        B{ 115 116 111 114 101 105 110 97 98 108 111 98 } f <person> person3 set
     "eddie" 10 3.14
         T{ timestamp f 2008 3 5 16 24 11 T{ duration f 0 0 0 0 0 0 } }
         T{ timestamp f 2008 11 22 0 0 0 T{ duration f 0 0 0 0 0 0 } }
         T{ timestamp f f f f 12 34 56 T{ duration f 0 0 0 0 0 0 } }
-        f H{ { 1 2 } { 3 4 } { 5 "lol" } } <person> person4 set ;
+        f H{ { 1 2 } { 3 4 } { 5 "lol" } } <person> person4 set ;
 
 : user-assigned-person-schema ( -- )
     person "PERSON"
@@ -146,20 +148,21 @@ SYMBOL: person4
         { "time" "T" TIME }
         { "blob" "B" BLOB }
         { "factor-blob" "FB" FACTOR-BLOB }
+        { "url" "U" URL }
     } define-persistent
-    1 "billy" 10 3.14 f f f f f <user-assigned-person> person1 set
-    2 "johnny" 10 3.14 f f f f f <user-assigned-person> person2 set
+    1 "billy" 10 3.14 f f f f f <user-assigned-person> person1 set
+    2 "johnny" 10 3.14 f f f f f <user-assigned-person> person2 set
     3 "teddy" 10 3.14
         T{ timestamp f 2008 3 5 16 24 11 T{ duration f 0 0 0 0 0 0 } }
         T{ timestamp f 2008 11 22 0 0 0 T{ duration f 0 0 0 0 0 0 } }
         T{ timestamp f f f f 12 34 56 T{ duration f 0 0 0 0 0 0 } }
         B{ 115 116 111 114 101 105 110 97 98 108 111 98 }
-        f <user-assigned-person> person3 set
+        f <user-assigned-person> person3 set
     4 "eddie" 10 3.14
         T{ timestamp f 2008 3 5 16 24 11 T{ duration f 0 0 0 0 0 0 } }
         T{ timestamp f 2008 11 22 0 0 0 T{ duration f 0 0 0 0 0 0 } }
         T{ timestamp f f f f 12 34 56 T{ duration f 0 0 0 0 0 0 } }
-        f H{ { 1 2 } { 3 4 } { 5 "lol" } } <user-assigned-person> person4 set ;
+        f H{ { 1 2 } { 3 4 } { 5 "lol" } } <user-assigned-person> person4 set ;
 
 TUPLE: paste n summary author channel mode contents timestamp annotations ;
 TUPLE: annotation n paste-id summary author mode contents ;