Merge pull request #533 from realm/mr/deprecate-type
Remove usage of Realm.Types in the spec and deprecate it
This commit is contained in:
commit
af0ddcdd3d
11
CHANGELOG.md
11
CHANGELOG.md
|
@ -1,3 +1,14 @@
|
||||||
|
x.x.x Release notes (yyyy-MM-dd)
|
||||||
|
=============================================================
|
||||||
|
### Breaking changes
|
||||||
|
* Deprecate `Realm.Types`. Please specify the type name as lowercase string instead.
|
||||||
|
|
||||||
|
### Enhancements
|
||||||
|
* None
|
||||||
|
|
||||||
|
### Bugfixes
|
||||||
|
* None
|
||||||
|
|
||||||
0.14.2 Release notes (2016-7-11)
|
0.14.2 Release notes (2016-7-11)
|
||||||
=============================================================
|
=============================================================
|
||||||
### Breaking changes
|
### Breaking changes
|
||||||
|
|
38
lib/index.js
38
lib/index.js
|
@ -41,18 +41,34 @@ if (typeof Realm != 'undefined') {
|
||||||
Object.defineProperties(realmConstructor.Collection.prototype, arrayMethods);
|
Object.defineProperties(realmConstructor.Collection.prototype, arrayMethods);
|
||||||
|
|
||||||
// TODO: Remove this now useless object.
|
// TODO: Remove this now useless object.
|
||||||
|
var types = Object.freeze({
|
||||||
|
'BOOL': 'bool',
|
||||||
|
'INT': 'int',
|
||||||
|
'FLOAT': 'float',
|
||||||
|
'DOUBLE': 'double',
|
||||||
|
'STRING': 'string',
|
||||||
|
'DATE': 'date',
|
||||||
|
'DATA': 'data',
|
||||||
|
'OBJECT': 'object',
|
||||||
|
'LIST': 'list',
|
||||||
|
});
|
||||||
Object.defineProperty(realmConstructor, 'Types', {
|
Object.defineProperty(realmConstructor, 'Types', {
|
||||||
value: Object.freeze({
|
get: function() {
|
||||||
'BOOL': 'bool',
|
if (typeof console != 'undefined') {
|
||||||
'INT': 'int',
|
/* global console */
|
||||||
'FLOAT': 'float',
|
/* eslint-disable no-console */
|
||||||
'DOUBLE': 'double',
|
var stack = new Error().stack.split("\n").slice(2).join("\n");
|
||||||
'STRING': 'string',
|
var msg = '`Realm.Types` is deprecated! Please specify the type name as lowercase string instead!\n'+stack;
|
||||||
'DATE': 'date',
|
if (console.warn != undefined) {
|
||||||
'DATA': 'data',
|
console.warn(msg);
|
||||||
'OBJECT': 'object',
|
}
|
||||||
'LIST': 'list',
|
else {
|
||||||
})
|
console.log(msg);
|
||||||
|
}
|
||||||
|
/* eslint-enable no-console */
|
||||||
|
}
|
||||||
|
return types;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = realmConstructor;
|
module.exports = realmConstructor;
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -o pipefail
|
||||||
|
set -e
|
||||||
|
|
||||||
|
while pgrep -q Simulator; do
|
||||||
|
# Kill all the current simulator processes as they may be from a
|
||||||
|
# different Xcode version
|
||||||
|
pkill Simulator 2>/dev/null || true
|
||||||
|
# CoreSimulatorService doesn't exit when sent SIGTERM
|
||||||
|
pkill -9 Simulator 2>/dev/null || true
|
||||||
|
done
|
||||||
|
|
||||||
|
# Shut down simulators until there's no booted ones left
|
||||||
|
# Only do one at a time because devices sometimes show up multiple times
|
||||||
|
while xcrun simctl list | grep -q Booted; do
|
||||||
|
xcrun simctl list | grep Booted | sed 's/.* (\(.*\)) (Booted)/\1/' | head -n 1 | xargs xcrun simctl shutdown
|
||||||
|
done
|
||||||
|
|
||||||
|
# Clean up all available simulators
|
||||||
|
(
|
||||||
|
previous_device=''
|
||||||
|
IFS=$'\n' # make newlines the only separator
|
||||||
|
for LINE in $(xcrun simctl list); do
|
||||||
|
if [[ $LINE =~ unavailable || $LINE =~ disconnected ]]; then
|
||||||
|
# skip unavailable simulators
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $LINE =~ "--" ]]; then
|
||||||
|
# Reset the last seen device so we won't consider devices with the same name to be duplicates
|
||||||
|
# if they appear in different sections.
|
||||||
|
previous_device=""
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
regex='^(.*) [(]([0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12})[)]'
|
||||||
|
if [[ $LINE =~ $regex ]]; then
|
||||||
|
device="${BASH_REMATCH[1]}"
|
||||||
|
guid="${BASH_REMATCH[2]}"
|
||||||
|
|
||||||
|
# Delete the simulator if it's a duplicate of the last seen one
|
||||||
|
# Otherwise delete all contents and settings for it
|
||||||
|
if [[ $device == $previous_device ]]; then
|
||||||
|
xcrun simctl delete $guid
|
||||||
|
else
|
||||||
|
xcrun simctl erase $guid
|
||||||
|
previous_device="$device"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
)
|
||||||
|
|
||||||
|
if [[ -a "${DEVELOPER_DIR}/Applications/iOS Simulator.app" ]]; then
|
||||||
|
open "${DEVELOPER_DIR}/Applications/iOS Simulator.app"
|
||||||
|
elif [[ -a "${DEVELOPER_DIR}/Applications/Simulator.app" ]]; then
|
||||||
|
open "${DEVELOPER_DIR}/Applications/Simulator.app"
|
||||||
|
fi
|
||||||
|
|
|
@ -30,16 +30,6 @@ cleanup() {
|
||||||
rm -f "$PACKAGER_OUT" "$LOGCAT_OUT"
|
rm -f "$PACKAGER_OUT" "$LOGCAT_OUT"
|
||||||
}
|
}
|
||||||
|
|
||||||
kill_ios_simulator() {
|
|
||||||
while pgrep -q Simulator; do
|
|
||||||
# Kill all the current simulator processes as they may be from a
|
|
||||||
# different Xcode version
|
|
||||||
pkill Simulator 2>/dev/null || true
|
|
||||||
# CoreSimulatorService doesn't exit when sent SIGTERM
|
|
||||||
pkill -9 Simulator 2>/dev/null || true
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
open_chrome() {
|
open_chrome() {
|
||||||
local dir
|
local dir
|
||||||
for dir in "$HOME/Applications" "/Applications"; do
|
for dir in "$HOME/Applications" "/Applications"; do
|
||||||
|
@ -65,7 +55,7 @@ start_packager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
xctest() {
|
xctest() {
|
||||||
kill_ios_simulator
|
${SRCROOT}/scripts/reset-simulators.sh
|
||||||
|
|
||||||
local dest="$(xcrun simctl list devices | grep -v unavailable | grep -m 1 -o '[0-9A-F\-]\{36\}')"
|
local dest="$(xcrun simctl list devices | grep -v unavailable | grep -m 1 -o '[0-9A-F\-]\{36\}')"
|
||||||
xcodebuild -scheme "$1" -configuration "$CONFIGURATION" -sdk iphonesimulator -destination id="$dest" build test
|
xcodebuild -scheme "$1" -configuration "$CONFIGURATION" -sdk iphonesimulator -destination id="$dest" build test
|
||||||
|
|
|
@ -50,13 +50,13 @@ module.exports = {
|
||||||
var prop = schemas.BasicTypes.properties[name];
|
var prop = schemas.BasicTypes.properties[name];
|
||||||
var type = typeof prop == 'object' ? prop.type : prop;
|
var type = typeof prop == 'object' ? prop.type : prop;
|
||||||
|
|
||||||
if (type == Realm.Types.FLOAT || type == Realm.Types.DOUBLE) {
|
if (type == 'float' || type == 'double') {
|
||||||
TestCase.assertEqualWithTolerance(object[name], basicTypesValues[name], 0.000001);
|
TestCase.assertEqualWithTolerance(object[name], basicTypesValues[name], 0.000001);
|
||||||
}
|
}
|
||||||
else if (type == Realm.Types.DATA) {
|
else if (type == 'data') {
|
||||||
TestCase.assertArraysEqual(new Uint8Array(object[name]), RANDOM_DATA);
|
TestCase.assertArraysEqual(new Uint8Array(object[name]), RANDOM_DATA);
|
||||||
}
|
}
|
||||||
else if (type == Realm.Types.DATE) {
|
else if (type == 'date') {
|
||||||
TestCase.assertEqual(object[name].getTime(), basicTypesValues[name].getTime());
|
TestCase.assertEqual(object[name].getTime(), basicTypesValues[name].getTime());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -100,13 +100,13 @@ module.exports = {
|
||||||
|
|
||||||
TestCase.assertEqual(nullObject[name], null);
|
TestCase.assertEqual(nullObject[name], null);
|
||||||
|
|
||||||
if (type == Realm.Types.FLOAT || type == Realm.Types.DOUBLE) {
|
if (type == 'float' || type == 'double') {
|
||||||
TestCase.assertEqualWithTolerance(object[name], basicTypesValues[name], 0.000001);
|
TestCase.assertEqualWithTolerance(object[name], basicTypesValues[name], 0.000001);
|
||||||
}
|
}
|
||||||
else if (type == Realm.Types.DATA) {
|
else if (type == 'data') {
|
||||||
TestCase.assertArraysEqual(new Uint8Array(object[name]), RANDOM_DATA);
|
TestCase.assertArraysEqual(new Uint8Array(object[name]), RANDOM_DATA);
|
||||||
}
|
}
|
||||||
else if (type == Realm.Types.DATE) {
|
else if (type == 'date') {
|
||||||
TestCase.assertEqual(object[name].getTime(), basicTypesValues[name].getTime());
|
TestCase.assertEqual(object[name].getTime(), basicTypesValues[name].getTime());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -42,9 +42,9 @@ function convertValue(value, schema, type) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
typeConverters[Realm.Types.DATE] = function(value) { return new Date(value); };
|
typeConverters['date'] = function(value) { return new Date(value); };
|
||||||
typeConverters[Realm.Types.DATA] = function(value) { return new Uint8Array(value); };
|
typeConverters['data'] = function(value) { return new Uint8Array(value); };
|
||||||
typeConverters[Realm.Types.OBJECT] = convertValue;
|
typeConverters['object'] = convertValue;
|
||||||
|
|
||||||
function runQuerySuite(suite) {
|
function runQuerySuite(suite) {
|
||||||
var realm = new Realm({schema: suite.schema});
|
var realm = new Realm({schema: suite.schema});
|
||||||
|
|
|
@ -116,7 +116,7 @@ module.exports = {
|
||||||
}, 'The schema should be an array of ObjectSchema objects');
|
}, 'The schema should be an array of ObjectSchema objects');
|
||||||
|
|
||||||
TestCase.assertThrows(function() {
|
TestCase.assertThrows(function() {
|
||||||
new Realm({schema: [{properties: {intCol: Realm.Types.INT}}]});
|
new Realm({schema: [{properties: {intCol: 'int'}}]});
|
||||||
}, 'The schema should be an array of ObjectSchema objects');
|
}, 'The schema should be an array of ObjectSchema objects');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ var Realm = require('realm');
|
||||||
exports.TestObject = {
|
exports.TestObject = {
|
||||||
name: 'TestObject',
|
name: 'TestObject',
|
||||||
properties: {
|
properties: {
|
||||||
doubleCol: Realm.Types.DOUBLE,
|
doubleCol: 'double',
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -31,9 +31,9 @@ function PersonObject() {}
|
||||||
PersonObject.schema = {
|
PersonObject.schema = {
|
||||||
name: 'PersonObject',
|
name: 'PersonObject',
|
||||||
properties: {
|
properties: {
|
||||||
name: Realm.Types.STRING,
|
name: 'string',
|
||||||
age: Realm.Types.DOUBLE,
|
age: 'double',
|
||||||
married: {type: Realm.Types.BOOL, default: false},
|
married: {type: 'bool', default: false},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
PersonObject.prototype.description = function() {
|
PersonObject.prototype.description = function() {
|
||||||
|
@ -54,26 +54,26 @@ exports.PersonList = {
|
||||||
exports.BasicTypes = {
|
exports.BasicTypes = {
|
||||||
name: 'BasicTypesObject',
|
name: 'BasicTypesObject',
|
||||||
properties: {
|
properties: {
|
||||||
boolCol: Realm.Types.BOOL,
|
boolCol: 'bool',
|
||||||
intCol: Realm.Types.INT,
|
intCol: 'int',
|
||||||
floatCol: Realm.Types.FLOAT,
|
floatCol: 'float',
|
||||||
doubleCol: Realm.Types.DOUBLE,
|
doubleCol: 'double',
|
||||||
stringCol: Realm.Types.STRING,
|
stringCol: 'string',
|
||||||
dateCol: Realm.Types.DATE,
|
dateCol: 'date',
|
||||||
dataCol: Realm.Types.DATA,
|
dataCol: 'data',
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.NullableBasicTypes = {
|
exports.NullableBasicTypes = {
|
||||||
name: 'NullableBasicTypesObject',
|
name: 'NullableBasicTypesObject',
|
||||||
properties: {
|
properties: {
|
||||||
boolCol: {type: Realm.Types.BOOL, optional: true},
|
boolCol: {type: 'bool', optional: true},
|
||||||
intCol: {type: Realm.Types.INT, optional: true},
|
intCol: {type: 'int', optional: true},
|
||||||
floatCol: {type: Realm.Types.FLOAT, optional: true},
|
floatCol: {type: 'float', optional: true},
|
||||||
doubleCol: {type: Realm.Types.DOUBLE, optional: true},
|
doubleCol: {type: 'double', optional: true},
|
||||||
stringCol: {type: Realm.Types.STRING, optional: true},
|
stringCol: {type: 'string', optional: true},
|
||||||
dateCol: {type: Realm.Types.DATE, optional: true},
|
dateCol: {type: 'date', optional: true},
|
||||||
dataCol: {type: Realm.Types.DATA, optional: true},
|
dataCol: {type: 'data', optional: true},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -92,8 +92,8 @@ exports.LinkTypes = {
|
||||||
name: 'LinkTypesObject',
|
name: 'LinkTypesObject',
|
||||||
properties: {
|
properties: {
|
||||||
objectCol: 'TestObject',
|
objectCol: 'TestObject',
|
||||||
objectCol1: {type: Realm.Types.OBJECT, objectType: 'TestObject'},
|
objectCol1: {type: 'object', objectType: 'TestObject'},
|
||||||
arrayCol: {type: Realm.Types.LIST, objectType: 'TestObject'},
|
arrayCol: {type: 'list', objectType: 'TestObject'},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -101,8 +101,8 @@ exports.IntPrimary = {
|
||||||
name: 'IntPrimaryObject',
|
name: 'IntPrimaryObject',
|
||||||
primaryKey: 'primaryCol',
|
primaryKey: 'primaryCol',
|
||||||
properties: {
|
properties: {
|
||||||
primaryCol: Realm.Types.INT,
|
primaryCol: 'int',
|
||||||
valueCol: Realm.Types.STRING,
|
valueCol: 'string',
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -110,8 +110,8 @@ exports.StringPrimary = {
|
||||||
name: 'StringPrimaryObject',
|
name: 'StringPrimaryObject',
|
||||||
primaryKey: 'primaryCol',
|
primaryKey: 'primaryCol',
|
||||||
properties: {
|
properties: {
|
||||||
primaryCol: Realm.Types.STRING,
|
primaryCol: 'string',
|
||||||
valueCol: Realm.Types.INT,
|
valueCol: 'int',
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -119,64 +119,64 @@ exports.AllTypes = {
|
||||||
name: 'AllTypesObject',
|
name: 'AllTypesObject',
|
||||||
primaryKey: 'primaryCol',
|
primaryKey: 'primaryCol',
|
||||||
properties: {
|
properties: {
|
||||||
primaryCol: Realm.Types.STRING,
|
primaryCol: 'string',
|
||||||
boolCol: Realm.Types.BOOL,
|
boolCol: 'bool',
|
||||||
intCol: Realm.Types.INT,
|
intCol: 'int',
|
||||||
floatCol: Realm.Types.FLOAT,
|
floatCol: 'float',
|
||||||
doubleCol: Realm.Types.DOUBLE,
|
doubleCol: 'double',
|
||||||
stringCol: Realm.Types.STRING,
|
stringCol: 'string',
|
||||||
dateCol: Realm.Types.DATE,
|
dateCol: 'date',
|
||||||
dataCol: Realm.Types.DATA,
|
dataCol: 'data',
|
||||||
objectCol: 'TestObject',
|
objectCol: 'TestObject',
|
||||||
arrayCol: {type: Realm.Types.LIST, objectType: 'TestObject'},
|
arrayCol: {type: 'list', objectType: 'TestObject'},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.DefaultValues = {
|
exports.DefaultValues = {
|
||||||
name: 'DefaultValuesObject',
|
name: 'DefaultValuesObject',
|
||||||
properties: {
|
properties: {
|
||||||
boolCol: {type: Realm.Types.BOOL, default: true},
|
boolCol: {type: 'bool', default: true},
|
||||||
intCol: {type: Realm.Types.INT, default: -1},
|
intCol: {type: 'int', default: -1},
|
||||||
floatCol: {type: Realm.Types.FLOAT, default: -1.1},
|
floatCol: {type: 'float', default: -1.1},
|
||||||
doubleCol: {type: Realm.Types.DOUBLE, default: -1.11},
|
doubleCol: {type: 'double', default: -1.11},
|
||||||
stringCol: {type: Realm.Types.STRING, default: 'defaultString'},
|
stringCol: {type: 'string', default: 'defaultString'},
|
||||||
dateCol: {type: Realm.Types.DATE, default: new Date(1.111)},
|
dateCol: {type: 'date', default: new Date(1.111)},
|
||||||
dataCol: {type: Realm.Types.DATA, default: new ArrayBuffer(1)},
|
dataCol: {type: 'data', default: new ArrayBuffer(1)},
|
||||||
objectCol: {type: 'TestObject', default: {doubleCol: 1}},
|
objectCol: {type: 'TestObject', default: {doubleCol: 1}},
|
||||||
nullObjectCol: {type: 'TestObject', default: null},
|
nullObjectCol: {type: 'TestObject', default: null},
|
||||||
arrayCol: {type: Realm.Types.LIST, objectType: 'TestObject', default: [{doubleCol: 2}]},
|
arrayCol: {type: 'list', objectType: 'TestObject', default: [{doubleCol: 2}]},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.QueryObject = {
|
exports.QueryObject = {
|
||||||
name: 'QueryObject',
|
name: 'QueryObject',
|
||||||
properties: [
|
properties: [
|
||||||
{name: 'bool1', type: Realm.Types.BOOL},
|
{name: 'bool1', type: 'bool'},
|
||||||
{name: 'bool2', type: Realm.Types.BOOL},
|
{name: 'bool2', type: 'bool'},
|
||||||
{name: 'int1', type: Realm.Types.INT},
|
{name: 'int1', type: 'int'},
|
||||||
{name: 'int2', type: Realm.Types.INT},
|
{name: 'int2', type: 'int'},
|
||||||
{name: 'float1', type: Realm.Types.FLOAT},
|
{name: 'float1', type: 'float'},
|
||||||
{name: 'float2', type: Realm.Types.FLOAT},
|
{name: 'float2', type: 'float'},
|
||||||
{name: 'double1', type: Realm.Types.DOUBLE},
|
{name: 'double1', type: 'double'},
|
||||||
{name: 'double2', type: Realm.Types.DOUBLE},
|
{name: 'double2', type: 'double'},
|
||||||
{name: 'string1', type: Realm.Types.STRING},
|
{name: 'string1', type: 'string'},
|
||||||
{name: 'string2', type: Realm.Types.STRING},
|
{name: 'string2', type: 'string'},
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.NullQueryObject = {
|
exports.NullQueryObject = {
|
||||||
name: 'NullQueryObject',
|
name: 'NullQueryObject',
|
||||||
properties: [
|
properties: [
|
||||||
{name: 'bool1', type: Realm.Types.BOOL},
|
{name: 'bool1', type: 'bool'},
|
||||||
{name: 'bool2', type: Realm.Types.BOOL},
|
{name: 'bool2', type: 'bool'},
|
||||||
{name: 'int1', type: Realm.Types.INT},
|
{name: 'int1', type: 'int'},
|
||||||
{name: 'int2', type: Realm.Types.INT},
|
{name: 'int2', type: 'int'},
|
||||||
{name: 'float1', type: Realm.Types.FLOAT},
|
{name: 'float1', type: 'float'},
|
||||||
{name: 'float2', type: Realm.Types.FLOAT},
|
{name: 'float2', type: 'float'},
|
||||||
{name: 'double1', type: Realm.Types.DOUBLE},
|
{name: 'double1', type: 'double'},
|
||||||
{name: 'double2', type: Realm.Types.DOUBLE},
|
{name: 'double2', type: 'double'},
|
||||||
{name: 'string1', type: Realm.Types.STRING},
|
{name: 'string1', type: 'string'},
|
||||||
{name: 'string2', type: Realm.Types.STRING},
|
{name: 'string2', type: 'string'},
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue