cloudfoundry/cloud_controller_ng — pull request #42 by youngm (2013-04-29 23:19:43+00:00)
Title: Change Route.host to use '*' instead of empty

This pull request replace https://github.com/cloudfoundry/cloud_controller_ng/pull/40

This patch is part of my work to support Oracle in the Cloud Controller.

While doing the conversion work I discovered an annoying Oracle 'feature' where an empty varchar is essentially equal to null. If you insert an empty string into oracle it will insert null into the column and fail any not null constraints you may have associated with the column. However, if you query for empty it will not match null columns.

I scanned through all of the CC code and pretty much all not null var chars are also validated as "validates_presence", which should be compatible with this Oracle behavior, except for Route.host.

From what I could gather by looking at the code, Route.Host is not null but default "". It seems that the purpose of this behavior is to assign "" the value of no host to ensure that a "validate_unique" against host and domain_id will always work.

In oracle this functionality is duplicated by using a null value since null == "". But in other databases you need to be sure that only "" or null is put in the database.

So in this patch I've actually changed the behavior of Route.host to use the character "*" as the wildcard host value.

I then updated the subsequent tests to make sure Route.host accepts "*" and empty and added a few more test to ensure that when a route is queried a widlcard value will be an empty string.