Forráskód Böngészése

Remove capitalized mongo tables (#2545)

* remove capitalized dropwizard mongo tables

* hopefully remove capitalized ulib mongo tables

* remove capitalized vibed mongo tables

* remove capitalized redstone mongo tables

* remove capitalized start mongo tables

* remove capitalized stream mongo tables

* remove capitalized hot mongo tables

* remove capitalized undertow mongo tables

* remove capitalized express mongo tables

* remove creation of uppercase mongo collections

* testing removal of travis-specific code for ulib

* maybe a better test

* checking if capital table names throw the same ulib error

* another test [ci fw-only C++/ulib]

* more test [ci fw-only C++/ulib]

* re-removed the uppercase mongo tables [ci fw-only C++/ulib]

* temporarily disable response trimming [ci fw-only C++/ulib]

* add response trimming back in

* hopefully fixed Yesod

* fixed kelp

* fixed tornado

* temporarily disable ffead-cpp Mongo Fortune tests until they are fixed to use the lower case tables

* a whole new dorld.

* a whole new dorld.
knewmanTE 8 éve
szülő
commit
189ca7892e

+ 0 - 3
frameworks/C++/ffead-cpp/benchmark_config.json

@@ -7,7 +7,6 @@
       "plaintext_url": "/te-benchmark/plaintext",
       "db_url": "/te-benchmark/db",
       "query_url": "/te-benchmark/queries?queries=",
-      "fortune_url": "/te-benchmark/fortunes",
       "update_url": "/te-benchmark/updates?queries=",
       "port": 8080,
       "approach": "Realistic",
@@ -77,7 +76,6 @@
       "plaintext_url": "/te-benchmark/plaintext",
       "db_url": "/te-benchmark/db",
       "query_url": "/te-benchmark/queries?queries=",
-      "fortune_url": "/te-benchmark/fortunes",
       "update_url": "/te-benchmark/updates?queries=",
       "port": 8080,
       "approach": "Realistic",
@@ -146,7 +144,6 @@
       "plaintext_url": "/te-benchmark/plaintext",
       "db_url": "/te-benchmark/db",
       "query_url": "/te-benchmark/queries?queries=",
-      "fortune_url": "/te-benchmark/fortunes",
       "update_url": "/te-benchmark/updates?queries=",
       "port": 8080,
       "approach": "Realistic",

+ 2 - 2
frameworks/D/vibed/source/mongodb.d

@@ -31,8 +31,8 @@ static this()
 {
 	import std.process : environment;
 	auto db = connectMongoDB(environment["DBHOST"]);
-	_worldCollection = db.getCollection("hello_world.World");
-	_fortuneCollection = db.getCollection("hello_world.Fortune");
+	_worldCollection = db.getCollection("hello_world.world");
+	_fortuneCollection = db.getCollection("hello_world.fortune");
 }
 
 class WebInterface {

+ 2 - 2
frameworks/Dart/redstone/server.dart

@@ -163,8 +163,8 @@ class PgTests {
 @Encode()
 class MongoTests {
   
-  static const worldCollection = "World";
-  static const fortuneCollection = "Fortune";
+  static const worldCollection = "world";
+  static const fortuneCollection = "fortune";
   
   MongoDb get mongoDb => app.request.attributes["dbConn"];
   

+ 2 - 2
frameworks/Dart/start/server.dart

@@ -74,8 +74,8 @@ main(List<String> args) {
       var mongoConfig = yaml.loadYaml(config);
       _mongoDb = new Db("mongodb://${mongoConfig["host"]}/${mongoConfig["database"]}");
       return _mongoDb.open().then((_) {
-        _worldCollection = _mongoDb.collection("World");
-        _fortuneCollection = _mongoDb.collection("Fortune");
+        _worldCollection = _mongoDb.collection("world");
+        _fortuneCollection = _mongoDb.collection("fortune");
       });
     }),
     new File('fortunes.mustache').readAsString().then((template) {

+ 2 - 2
frameworks/Dart/stream/server.dart

@@ -106,8 +106,8 @@ main(List<String> args) {
        var mongoConfig = yaml.loadYaml(config);
        _mongoDb = new Db("mongodb://${mongoConfig["host"]}/${mongoConfig["database"]}");
        return _mongoDb.open().then((_) {
-         _worldCollection = _mongoDb.collection("World");
-         _fortuneCollection = _mongoDb.collection("Fortune");
+         _worldCollection = _mongoDb.collection("world");
+         _fortuneCollection = _mongoDb.collection("fortune");
        });
      })
    ]).then((_) {

+ 5 - 5
frameworks/Groovy/hot/shows/benchmark.show.groovy

@@ -30,7 +30,7 @@ rest.get("/json").then {
 }
 
 rest.get('/db/mongodb').then {
-	mongo.World.findOne([_id:generate()]).promise()
+	mongo.world.findOne([_id:generate()]).promise()
 }
 
 rest.get('/queries/mongodb').then { req ->
@@ -42,7 +42,7 @@ rest.get('/queries/mongodb').then { req ->
 
 	(1..numQueries).each { i ->
 		promise = promise.then { 
-			mongo.World.findOne(_id:generate()).promise()
+			mongo.world.findOne(_id:generate()).promise()
 		}.then { world ->
 			results << world
 			results
@@ -54,7 +54,7 @@ rest.get('/queries/mongodb').then { req ->
 
 rest.get('/fortunes/mongodb').then {
 
-	mongo.Fortune.find().promise().then { fortunes ->
+	mongo.fortune.find().promise().then { fortunes ->
 		
 		fortunes << [_id:'0.', message:'Additional fortune added at request time.']
 		fortunes.each {
@@ -85,10 +85,10 @@ rest.get('/updates/mongodb').then { req ->
 		def genId = generate()
 
 		promise = promise.then { 
-			mongo.World.findOne(_id:genId).promise()
+			mongo.world.findOne(_id:genId).promise()
 		}.then { world ->
 			world.randomNumber = generate()
-			mongo.World.update([_id:genId],[$set:[randomNumber:world.randomNumber]]).then {
+			mongo.world.update([_id:genId],[$set:[randomNumber:world.randomNumber]]).then {
 				world
 			}
 		}.then { world ->

+ 1 - 1
frameworks/Haskell/yesod/yesod-mysql-mongo/src/yesod.hs

@@ -200,7 +200,7 @@ intQuery db toKey i = do
 
 rawMongoIntQuery :: Mongo.Val v => v -> Handler Value
 rawMongoIntQuery i = do
-    Just x <- runMongoDB $ Mongo.findOne (Mongo.select ["id" =: i] "World")
+    Just x <- runMongoDB $ Mongo.findOne (Mongo.select ["id" =: i] "world")
     return $ documentToJson x
 
 intUpdate :: (Functor m, Monad m, MonadIO m

+ 2 - 2
frameworks/Java/dropwizard/src/main/java/com/example/helloworld/HelloMongoService.java

@@ -40,10 +40,10 @@ public class HelloMongoService extends Application<HelloMongoConfiguration> {
         final DB db = mongoClient.getDB(config.getMongo().getDb());
         final ObjectMapper mongoJackMapper = MongoJackModule.configure(Jackson.newObjectMapper());
         final JacksonDBCollection<World, Integer> worlds =
-                JacksonDBCollection.wrap(db.getCollection("World"), World.class, Integer.class, mongoJackMapper);
+                JacksonDBCollection.wrap(db.getCollection("world"), World.class, Integer.class, mongoJackMapper);
 
         final JacksonDBCollection<Fortune, Integer> fortunes =
-                JacksonDBCollection.wrap(db.getCollection("Fortune"), Fortune.class, Integer.class, mongoJackMapper);
+                JacksonDBCollection.wrap(db.getCollection("fortune"), Fortune.class, Integer.class, mongoJackMapper);
 
         environment.jersey().register(new WorldResource(new WorldMongoImpl(worlds))); // Test types 2, 3 & 5: Single database query, Multiple database queries & Database updates
         environment.jersey().register(new FortuneResource(new FortuneMongoImpl(fortunes))); // Test type 4: Fortunes

+ 1 - 1
frameworks/Java/dropwizard/src/main/java/com/example/helloworld/db/model/Fortune.java

@@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
 import javax.persistence.*;
 
 @Entity
-@Table(name = "Fortune")
+@Table(name = "fortune")
 public class Fortune implements Comparable<Fortune> {
 
     @Id

+ 1 - 1
frameworks/Java/dropwizard/src/main/java/com/example/helloworld/db/model/World.java

@@ -8,7 +8,7 @@ import javax.persistence.Id;
 import javax.persistence.Table;
 
 @Entity
-@Table(name = "World")
+@Table(name = "world")
 public class World {
 
     @Id

+ 1 - 1
frameworks/Java/undertow/src/main/java/hello/DbMongoHandler.java

@@ -41,7 +41,7 @@ final class DbMongoHandler implements HttpHandler {
     
     World[] worlds = new World[queries];
     for (int i = 0; i < queries; i++) {
-      DBObject object = database.getCollection("World").findOne(
+      DBObject object = database.getCollection("world").findOne(
           new BasicDBObject("_id", Helper.randomWorld()));
       worlds[i] = new World(
           //

+ 1 - 1
frameworks/Java/undertow/src/main/java/hello/FortunesMongoHandler.java

@@ -36,7 +36,7 @@ final class FortunesMongoHandler implements HttpHandler {
       return;
     }
     List<Fortune> fortunes = new ArrayList<>();
-    DBCursor cursor = database.getCollection("Fortune").find();
+    DBCursor cursor = database.getCollection("fortune").find();
     while (cursor.hasNext()) {
       DBObject object = cursor.next();
       fortunes.add(new Fortune(

+ 2 - 2
frameworks/Java/undertow/src/main/java/hello/UpdatesMongoHandler.java

@@ -42,7 +42,7 @@ final class UpdatesMongoHandler implements HttpHandler {
       // we could technically avoid doing either of those things and still
       // produce the correct output and side effects.
       //
-      DBObject object = database.getCollection("World").findOne(key);
+      DBObject object = database.getCollection("world").findOne(key);
       
       @SuppressWarnings("unused")
       // Per test requirement the old value must be read
@@ -50,7 +50,7 @@ final class UpdatesMongoHandler implements HttpHandler {
       
       int newRandomNumber = Helper.randomWorld();
       object.put("randomNumber", newRandomNumber);
-      database.getCollection("World").update(key, object);
+      database.getCollection("world").update(key, object);
       worlds[i] = new World(id, newRandomNumber);
     }
     exchange.getResponseHeaders().put(

+ 2 - 2
frameworks/JavaScript/express/app.js

@@ -25,7 +25,7 @@ var WorldSchema = new mongoose.Schema({
   }, {
     collection: 'world'
   }),
-  MWorld = conn.model('World', WorldSchema);
+  MWorld = conn.model('world', WorldSchema);
 
 var FortuneSchema = new mongoose.Schema({
     id          : Number,
@@ -33,7 +33,7 @@ var FortuneSchema = new mongoose.Schema({
   }, {
     collection: 'fortune'
   }),
-  MFortune = conn.model('Fortune', FortuneSchema);
+  MFortune = conn.model('fortune', FortuneSchema);
 
 var sequelize = new Sequelize('hello_world', 'benchmarkdbuser', 'benchmarkdbpass', {
   host: 'TFB-database',

+ 2 - 2
frameworks/Perl/kelp/app.pl

@@ -10,8 +10,8 @@ module 'JSON::XS';
 
 my $mongo   = MongoDB::MongoClient->new( host => 'localhost', port => 27017 );
 my $mdb     = $mongo->get_database('hello_world');
-my $world   = $mdb->get_collection('World');
-my $fortune = $mdb->get_collection('Fortune');
+my $world   = $mdb->get_collection('world');
+my $fortune = $mdb->get_collection('fortune');
 
 my $dbh = DBI->connect(
     "dbi:mysql:database=hello_world;host=localhost;port=3306",

+ 5 - 5
frameworks/Python/tornado/server_py2.py

@@ -21,7 +21,7 @@ class SingleQueryHandler(JsonHandler):
 
     @gen.coroutine
     def get(self):
-        world = yield db.World.find_one(randint(1, 10000))
+        world = yield db.world.find_one(randint(1, 10000))
         world = {self.ID: int(world['_id']),
                  self.RANDOM_NUMBER: int(world[self.RANDOM_NUMBER])
                  }
@@ -43,7 +43,7 @@ class MultipleQueriesHandler(JsonHandler):
             elif queries > 500:
                 queries = 500
 
-        worlds = yield [db.World.find_one(randint(1, 10000)) for _ in xrange(queries)]
+        worlds = yield [db.world.find_one(randint(1, 10000)) for _ in xrange(queries)]
 
         worlds = [{self.ID: int(world['_id']),
                    self.RANDOM_NUMBER: int(world[self.RANDOM_NUMBER])}
@@ -68,10 +68,10 @@ class UpdateHandler(JsonHandler):
         worlds = []
         updates = []
         for _ in xrange(queries):
-            world = yield db.World.find_one(randint(1, 10000))
+            world = yield db.world.find_one(randint(1, 10000))
             new_value = randint(1, 10000)
 
-            updates.append(db.World.update_one({'_id': world['_id']}, {"$set": {self.RANDOM_NUMBER: new_value}}))
+            updates.append(db.world.update_one({'_id': world['_id']}, {"$set": {self.RANDOM_NUMBER: new_value}}))
             worlds.append({self.ID: world['_id'],
                    self.RANDOM_NUMBER: world[self.RANDOM_NUMBER]})
 
@@ -83,7 +83,7 @@ class FortuneHandler(HtmlHandler):
     @gen.coroutine
     def get(self):
         fortunes = []
-        cursor = db.Fortune.find()
+        cursor = db.fortune.find()
 
         while (yield cursor.fetch_next):
             fortunes.append(cursor.next_object())

+ 5 - 5
frameworks/Python/tornado/server_py3.py

@@ -22,7 +22,7 @@ options.define('backlog', default=8192, type=int, help="Server backlog")
 class SingleQueryHandler(JsonHandler):
 
     async def get(self):
-        world = await db.World.find_one(randint(1, 10000))
+        world = await db.world.find_one(randint(1, 10000))
         world = {self.ID: int(world['_id']),
                  self.RANDOM_NUMBER: int(world[self.RANDOM_NUMBER])
                  }
@@ -44,7 +44,7 @@ class MultipleQueriesHandler(JsonHandler):
                 queries = 500
 
         worlds = []
-        for future in [db.World.find_one(randint(1, 10000)) for _ in range(queries)]:
+        for future in [db.world.find_one(randint(1, 10000)) for _ in range(queries)]:
             world = await future
 
             worlds.append({self.ID: int(world['_id']),
@@ -66,12 +66,12 @@ class UpdateHandler(JsonHandler):
                 queries = 500
 
         worlds = []
-        futures = [db.World.find_one(randint(1, 10000)) for _ in range(queries)]
+        futures = [db.world.find_one(randint(1, 10000)) for _ in range(queries)]
 
         for world in futures:
             world = await world
             new_value = randint(1, 10000)
-            await db.World.update_one({'_id': world['_id']}, {"$set": {self.RANDOM_NUMBER: new_value}})
+            await db.world.update_one({'_id': world['_id']}, {"$set": {self.RANDOM_NUMBER: new_value}})
 
             worlds.append({self.ID: int(world['_id']),
                     self.RANDOM_NUMBER: world[self.RANDOM_NUMBER]})
@@ -82,7 +82,7 @@ class FortuneHandler(HtmlHandler):
     async def get(self):
         fortunes = []
 
-        async for fortune in db.Fortune.find():
+        async for fortune in db.fortune.find():
             fortunes.append(fortune)
         fortunes.append({self.ID: 0, 'message': 'Additional fortune added at request time.'})
 

+ 1 - 29
toolset/setup/linux/databases/mongodb/create.js

@@ -22,32 +22,4 @@ db.fortune.save( {_id: 10, id: 10, message: 'Computers make very fast, very accu
 db.fortune.save( {_id: 11, id: 11, message: '<script>alert("This should not be displayed in a browser alert box.");</script>'} );
 db.fortune.save( {_id: 12, id: 12, message: 'フレームワークのベンチマーク'} );
 
-db.fortune.ensureIndex({_id: 1})
-
-
-// Capitalization matters apparently
-use hello_world
-db.World.drop()
-for (var i = 1; i <= 10000; i++) {
-  db.World.save( { _id: i, id: i, randomNumber: (Math.floor(Math.random() * 10000) + 1) })
-}
-
-// http://docs.mongodb.org/manual/applications/optimization/
-db.World.ensureIndex({_id: 1})
-
-db.Fortune.drop()
-
-db.Fortune.save( {_id: 1, id: 1, message: 'fortune: No such file or directory'} );
-db.Fortune.save( {_id: 2, id: 2, message: "A computer scientist is someone who fixes things that aren't broken."} );
-db.Fortune.save( {_id: 3, id: 3, message: 'After enough decimal places, nobody gives a damn.'} );
-db.Fortune.save( {_id: 4, id: 4, message: 'A bad random number generator: 1, 1, 1, 1, 1, 4.33e+67, 1, 1, 1'} );
-db.Fortune.save( {_id: 5, id: 5, message: 'A computer program does what you tell it to do, not what you want it to do.'} );
-db.Fortune.save( {_id: 6, id: 6, message: 'Emacs is a nice operating system, but I prefer UNIX. — Tom Christaensen'} );
-db.Fortune.save( {_id: 7, id: 7, message: 'Any program that runs right is obsolete.'} );
-db.Fortune.save( {_id: 8, id: 8, message: 'A list is only as strong as its weakest link. — Donald Knuth'} );
-db.Fortune.save( {_id: 9, id: 9, message: 'Feature: A bug with seniority.'} );
-db.Fortune.save( {_id: 10, id: 10, message: 'Computers make very fast, very accurate mistakes.'} );
-db.Fortune.save( {_id: 11, id: 11, message: '<script>alert("This should not be displayed in a browser alert box.");</script>'} );
-db.Fortune.save( {_id: 12, id: 12, message: 'フレームワークのベンチマーク'} );
-
-db.Fortune.ensureIndex({_id: 1})
+db.fortune.ensureIndex({_id: 1})