Permalink
Browse files

Fix for serialization of undefined values, fixing sql db create using…

… username/password
  • Loading branch information...
christav committed Mar 22, 2013
1 parent 61cac7a commit 58ffca3ebb13423b4ed3c5e345a64382b3445e63
Showing with 6 additions and 5 deletions.
  1. +1 −1 lib/services/sqlAzure/models/databaseresult.js
  2. +5 −4 lib/util/odatahandler.js
@@ -22,7 +22,7 @@ exports.serialize = function (databaseName, collation, edition, maxSizeInGB) {
var databaseDescription = { };
databaseDescription['CollationName'] = { '$': { 'type': 'Edm.String' }, '_': collation };
- databaseDescription['CreationDate'] = { '$': { 'm:type': 'Edm.DateTime' }, '_': '0001-01-01T00:00:00' };
+ databaseDescription['CreationDate'] = { '$': { 'type': 'Edm.DateTime' }, '_': '0001-01-01T00:00:00' };
databaseDescription['Edition'] = { '$': { 'type': 'Edm.String' }, '_': edition };
databaseDescription['Id'] = { '$': { 'type': 'Edm.Int32' }, '_': 0 };
databaseDescription['IsFederationRoot'] = { '$': { 'type': 'Edm.Boolean' }, '_': null };
View
@@ -153,7 +153,7 @@ OdataHandler.prototype._setProperty = function (entity, propertyName, value, typ
OdataHandler.prototype.serialize = function (entity, skipType) {
var properties = {};
- for (var name in entity) {
+ Object.keys(entity).forEach(function (name) {
if (name !== '_') {
properties[OdataHandler.NSDATA + ':' + name] = { };
properties[OdataHandler.NSDATA + ':' + name][Constants.XML_METADATA_MARKER] = {};
@@ -162,12 +162,13 @@ OdataHandler.prototype.serialize = function (entity, skipType) {
var propertyValue = null;
if (entity[name] &&
- entity[name][Constants.XML_VALUE_MARKER] !== undefined &&
entity[name][Constants.XML_METADATA_MARKER] !== undefined &&
entity[name][Constants.XML_METADATA_MARKER].type !== undefined) {
- propertyValue = edmType.serializeValue(entity[name][Constants.XML_METADATA_MARKER].type, entity[name][Constants.XML_VALUE_MARKER]);
propertyType = entity[name][Constants.XML_METADATA_MARKER].type;
+ if (entity[name][Constants.XML_VALUE_MARKER] !== undefined) {
+ propertyValue = edmType.serializeValue(propertyType, entity[name][Constants.XML_VALUE_MARKER]);
+ }
}
else {
if (entity[name] !== undefined && entity[name] !== null) {
@@ -187,7 +188,7 @@ OdataHandler.prototype.serialize = function (entity, skipType) {
properties[OdataHandler.NSDATA + ':' + name][Constants.XML_METADATA_MARKER][OdataHandler.NSMETA + ':null'] = true;
}
}
- }
+ });
return atomHandler.serializeEntry({ 'm:properties': properties }, [
{

0 comments on commit 58ffca3

Please sign in to comment.