Announcement Announcement Module
Collapse
No announcement yet.
SimpleMongoDbFactory database name constraints Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SimpleMongoDbFactory database name constraints

    The constructor of SimpleMongoDbFactory implements a constraint for the MongoDB database name.

    Code:
    	private SimpleMongoDbFactory(Mongo mongo, String databaseName, UserCredentials credentials,
    			boolean mongoInstanceCreated) {
    		...
    		Assert.isTrue(databaseName.matches("[\\w-]+"),
    				"Database name must only contain letters, numbers, underscores and dashes!");
    This constraint is not consistent with the MongoDB documentation. In "MongoDB The Definitive Guide" page 9 states:

    Database names can be any UTF-8 string, with the following restrictions:
    The empty string ("") is not a valid database name.
    A database name cannot contain any of these characters: ' ' (a single space), ., $, /, \, or \0 (the null character).
    Database names should be all lowercase.
    Database names are limited to a maximum of 64 bytes.
    In our environment we are using database names that contain characters # and : as well, e.g. maphub:tst#tst#Test. This naming scheme cannot be implemented with spring-data-mongodb, but is allowed in MongoDB. Is there a way to circumvent the restriction in SimpleMongoDbFactory?

    Thanks in advance,
    Lars
Working...
X