Browse Source

Lowercased psql randomNumber query for dart, stream, start

Michael Robertson 12 years ago
parent
commit
71dbbd8b83
3 changed files with 32 additions and 32 deletions
  1. 13 13
      dart-start/server.dart
  2. 12 12
      dart-stream/server.dart
  3. 7 7
      dart/server.dart

+ 13 - 13
dart-start/server.dart

@@ -45,11 +45,11 @@ class Fortune implements Comparable<Fortune> {
 
 class World {
   int id;
-  int randomNumber;
+  int randomnumber;
 
-  World(this.id, this.randomNumber);
+  World(this.id, this.randomnumber);
 
-  toJson() => { "id": id, "randomNumber": randomNumber };
+  toJson() => { "id": id, "randomnumber": randomnumber };
 }
 
 main() {
@@ -154,13 +154,13 @@ main() {
           Future.wait(new List.generate(queries, (_) {
             return _query()
                 .then((world) {
-                  world.randomNumber = _RANDOM.nextInt(_WORLD_TABLE_SIZE) + 1;
+                  world.randomnumber = _RANDOM.nextInt(_WORLD_TABLE_SIZE) + 1;
                   return _connectionPool.connect()
                       .then((connection) {
                         return connection.execute(
-                              'UPDATE "World" SET "randomNumber" = @randomNumber WHERE "id" = @id;',
+                              'UPDATE "World" SET "randomnumber" = @randomnumber WHERE "id" = @id;',
                               { 
-                                'randomNumber': world.randomNumber,
+                                'randomnumber': world.randomnumber,
                                 'id': world.id 
                               }
                             )
@@ -186,7 +186,7 @@ main() {
               var collectionData = new List.generate(_WORLD_TABLE_SIZE, (index) {
                 return {
                   "id": index + 1,
-                  "randomNumber": _RANDOM.nextInt(_WORLD_TABLE_SIZE)
+                  "randomnumber": _RANDOM.nextInt(_WORLD_TABLE_SIZE)
                 };
               });
               return _worldCollection.insertAll(collectionData); 
@@ -224,7 +224,7 @@ main() {
           _mongoQuery().then((data) {
             request.response.json({
               "id": data["id"],
-              "randomNumber": data["randomNumber"]
+              "randomnumber": data["randomnumber"]
             });
           });
         });
@@ -247,7 +247,7 @@ main() {
               var results = response.map((world) {
                 return {
                   "id": world["id"],
-                  "randomNumber": world["randomNumber"]
+                  "randomnumber": world["randomnumber"]
                 };
               });
               request.response.send(json.stringify(results.toList()));
@@ -263,7 +263,7 @@ main() {
           Future.wait(new List.generate(queries, (index) {
             return _mongoQuery()
                 .then((world) {
-                  world["randomNumber"] = _RANDOM.nextInt(_WORLD_TABLE_SIZE);
+                  world["randomnumber"] = _RANDOM.nextInt(_WORLD_TABLE_SIZE);
                   return _worldCollection.update( { "_id": world["_id"] }, world)
                       .then((_) => world);
                 });
@@ -272,7 +272,7 @@ main() {
             var result = worlds.map((world) {
               return {
                 "id": world["id"],
-                "randomNumber": world["randomNumber"]
+                "randomnumber": world["randomnumber"]
               };
             });
             request.response.send(json.stringify(result.toList()));
@@ -341,7 +341,7 @@ _parseQueriesParam(param) {
 _query() {
   return _connectionPool.connect().then((connection) {
     return connection
-      .query('SELECT "id", "randomNumber" FROM "World" WHERE id = @id;', { 'id': _RANDOM.nextInt(_WORLD_TABLE_SIZE) + 1 })
+      .query('SELECT "id", "randomnumber" FROM "World" WHERE id = @id;', { 'id': _RANDOM.nextInt(_WORLD_TABLE_SIZE) + 1 })
       .single
       .then((row) =>new World(row[0], row[1]))
       .whenComplete(() {
@@ -355,4 +355,4 @@ _mongoQuery() {
   return _worldCollection.findOne({
     "id": _RANDOM.nextInt(_WORLD_TABLE_SIZE) + 1
   });
-}
+}

+ 12 - 12
dart-stream/server.dart

@@ -76,11 +76,11 @@ class Fortune implements Comparable<Fortune> {
 
 class World {
   int id;
-  int randomNumber;
+  int randomnumber;
 
-  World(this.id, this.randomNumber);
+  World(this.id, this.randomnumber);
 
-  toJson() => { "id": id, "randomNumber": randomNumber };
+  toJson() => { "id": id, "randomnumber": randomnumber };
 }
 
 main() {
@@ -146,13 +146,13 @@ _updatesTest(HttpConnect connect) {
   return Future.wait(new List.generate(queries, (_) {
       return _query()
           .then((world) {
-            world.randomNumber = _RANDOM.nextInt(_WORLD_TABLE_SIZE) + 1;
+            world.randomnumber = _RANDOM.nextInt(_WORLD_TABLE_SIZE) + 1;
             return _connectionPool.connect()
               .then((connection) {
                 return connection.execute(
-                      'UPDATE "World" SET "randomNumber" = @randomNumber WHERE "id" = @id;',
+                      'UPDATE "World" SET "randomnumber" = @randomnumber WHERE "id" = @id;',
                       { 
-                        'randomNumber': world.randomNumber,
+                        'randomnumber': world.randomnumber,
                         'id': world.id 
                       }
                   )
@@ -188,7 +188,7 @@ _dbMongoTest(HttpConnect connect) {
   return _mongoQuery().then((data) {
     connect.response.write(json.stringify({
       "id": data["id"],
-      "randomNumber": data["randomNumber"]
+      "randomnumber": data["randomnumber"]
     }));
   });
 }
@@ -207,7 +207,7 @@ _queriesMongoTest(HttpConnect connect) {
       var results = response.map((world) {
         return {
           "id": world["id"],
-          "randomNumber": world["randomNumber"]
+          "randomnumber": world["randomnumber"]
         };
       });
       connect.response.write(json.stringify(results.toList()));
@@ -220,7 +220,7 @@ _updatesMongoTest(HttpConnect connect) {
   return Future.wait(new List.generate(queries, (index) {
       return _mongoQuery()
           .then((world) {
-            world["randomNumber"] = _RANDOM.nextInt(_WORLD_TABLE_SIZE);
+            world["randomnumber"] = _RANDOM.nextInt(_WORLD_TABLE_SIZE);
             return _worldCollection.update( { "_id": world["_id"] }, world)
                 .then((_) => world);
           });
@@ -229,7 +229,7 @@ _updatesMongoTest(HttpConnect connect) {
       var result = worlds.map((world) {
         return {
           "id": world["id"],
-          "randomNumber": world["randomNumber"]
+          "randomnumber": world["randomnumber"]
         };
       });
       connect.response.write(json.stringify(result.toList()));
@@ -288,7 +288,7 @@ _parseQueriesParam(param) {
 _query() {
   return _connectionPool.connect().then((connection) {
     return connection
-      .query('SELECT "id", "randomNumber" FROM "World" WHERE id = @id;', { 'id': _RANDOM.nextInt(_WORLD_TABLE_SIZE) + 1 })
+      .query('SELECT "id", "randomnumber" FROM "World" WHERE id = @id;', { 'id': _RANDOM.nextInt(_WORLD_TABLE_SIZE) + 1 })
       .single
       .then((row) =>new World(row[0], row[1]))
       .whenComplete(() {
@@ -302,4 +302,4 @@ _mongoQuery() {
   return _worldCollection.findOne({
     "id": _RANDOM.nextInt(_WORLD_TABLE_SIZE) + 1
   });
-}
+}

+ 7 - 7
dart/server.dart

@@ -28,11 +28,11 @@ main() {
 /// The entity used in the database query and update tests.
 class World {
   int id;
-  int randomNumber;
+  int randomnumber;
 
-  World(this.id, this.randomNumber);
+  World(this.id, this.randomnumber);
 
-  toJson() => { 'id': id, 'randomNumber': randomNumber };
+  toJson() => { 'id': id, 'randomnumber': randomnumber };
 }
 
 /// The entity used in the fortunes test.
@@ -167,7 +167,7 @@ _queryRandom() {
   return _connectionPool.connect()
       .then((connection) {
         return connection.query(
-            'SELECT id, randomNumber FROM world WHERE id = @id;',
+            'SELECT id, randomnumber FROM world WHERE id = @id;',
             { 'id': _RANDOM.nextInt(_WORLD_TABLE_SIZE) + 1 })
             //
             // The benchmark's constraints tell us there is exactly one row.
@@ -216,11 +216,11 @@ _updatesTest(request) {
   Future.wait(new List.generate(queries, (_) {
     return _queryRandom()
         .then((world) {
-          world.randomNumber = _RANDOM.nextInt(_WORLD_TABLE_SIZE) + 1;
+          world.randomnumber = _RANDOM.nextInt(_WORLD_TABLE_SIZE) + 1;
           return _connectionPool.connect().then((connection) {
             return connection.execute(
-                'UPDATE world SET randomNumber = @randomNumber WHERE id = @id;',
-                { 'randomNumber': world.randomNumber, 'id': world.id })
+                'UPDATE world SET randomnumber = @randomnumber WHERE id = @id;',
+                { 'randomnumber': world.randomnumber, 'id': world.id })
                 .whenComplete(() { connection.close(); });
           }).then((_) => world);
         });