kopia lustrzana https://github.com/FacilMap/facilmap
Round integers to avoid error on Postgres
rodzic
f456da2e7a
commit
9e2d259f07
|
@ -90,9 +90,30 @@ export default class DatabaseLines {
|
||||||
width : { type: DataTypes.INTEGER.UNSIGNED, allowNull: false, defaultValue: 4, validate: { min: 1 } },
|
width : { type: DataTypes.INTEGER.UNSIGNED, allowNull: false, defaultValue: 4, validate: { min: 1 } },
|
||||||
name : { type: DataTypes.TEXT, allowNull: true, get: function(this: LineModel) { return this.getDataValue("name") || "Untitled line"; } },
|
name : { type: DataTypes.TEXT, allowNull: true, get: function(this: LineModel) { return this.getDataValue("name") || "Untitled line"; } },
|
||||||
distance : { type: DataTypes.FLOAT(24, 2).UNSIGNED, allowNull: true },
|
distance : { type: DataTypes.FLOAT(24, 2).UNSIGNED, allowNull: true },
|
||||||
time : { type: DataTypes.INTEGER.UNSIGNED, allowNull: true },
|
time : {
|
||||||
ascent : { type: DataTypes.INTEGER.UNSIGNED, allowNull: true },
|
type: DataTypes.INTEGER.UNSIGNED,
|
||||||
descent : { type: DataTypes.INTEGER.UNSIGNED, allowNull: true },
|
allowNull: true,
|
||||||
|
set: function(this: LineModel, v: number | null) {
|
||||||
|
// Round number to avoid integer column error in Postgres
|
||||||
|
this.setDataValue("time", v != null ? Math.round(v) : v);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
ascent : {
|
||||||
|
type: DataTypes.INTEGER.UNSIGNED,
|
||||||
|
allowNull: true,
|
||||||
|
set: function(this: LineModel, v: number | null) {
|
||||||
|
// Round number to avoid integer column error in Postgres
|
||||||
|
this.setDataValue("ascent", v != null ? Math.round(v) : v);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
descent : {
|
||||||
|
type: DataTypes.INTEGER.UNSIGNED,
|
||||||
|
allowNull: true,
|
||||||
|
set: function(this: LineModel, v: number | null) {
|
||||||
|
// Round number to avoid integer column error in Postgres
|
||||||
|
this.setDataValue("descent", v != null ? Math.round(v) : v);
|
||||||
|
}
|
||||||
|
},
|
||||||
top: getLatType(),
|
top: getLatType(),
|
||||||
bottom: getLatType(),
|
bottom: getLatType(),
|
||||||
left: getLonType(),
|
left: getLonType(),
|
||||||
|
@ -120,7 +141,14 @@ export default class DatabaseLines {
|
||||||
pos: getPosType(),
|
pos: getPosType(),
|
||||||
zoom: { type: DataTypes.INTEGER.UNSIGNED, allowNull: false, validate: { min: 1, max: 20 } },
|
zoom: { type: DataTypes.INTEGER.UNSIGNED, allowNull: false, validate: { min: 1, max: 20 } },
|
||||||
idx: { type: DataTypes.INTEGER.UNSIGNED, allowNull: false },
|
idx: { type: DataTypes.INTEGER.UNSIGNED, allowNull: false },
|
||||||
ele: { type: DataTypes.INTEGER, allowNull: true }
|
ele: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
allowNull: true,
|
||||||
|
set: function(this: LinePointModel, v: number | null) {
|
||||||
|
// Round number to avoid integer column error in Postgres
|
||||||
|
this.setDataValue("ele", v != null ? Math.round(v) : v);
|
||||||
|
}
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
sequelize: this._db._conn,
|
sequelize: this._db._conn,
|
||||||
indexes: [
|
indexes: [
|
||||||
|
|
|
@ -43,7 +43,14 @@ export default class DatabaseMarkers {
|
||||||
size : { type: DataTypes.INTEGER.UNSIGNED, allowNull: false, defaultValue: 25, validate: { min: 15 } },
|
size : { type: DataTypes.INTEGER.UNSIGNED, allowNull: false, defaultValue: 25, validate: { min: 15 } },
|
||||||
symbol : { type: DataTypes.TEXT, allowNull: true },
|
symbol : { type: DataTypes.TEXT, allowNull: true },
|
||||||
shape : { type: DataTypes.TEXT, allowNull: true },
|
shape : { type: DataTypes.TEXT, allowNull: true },
|
||||||
ele: { type: DataTypes.INTEGER, allowNull: true }
|
ele: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
allowNull: true,
|
||||||
|
set: function(this: MarkerModel, v: number | null) {
|
||||||
|
// Round number to avoid integer column error in Postgres
|
||||||
|
this.setDataValue("ele", v != null ? Math.round(v) : v);
|
||||||
|
}
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
sequelize: this._db._conn,
|
sequelize: this._db._conn,
|
||||||
// pos index is created in migration
|
// pos index is created in migration
|
||||||
|
|
|
@ -40,7 +40,14 @@ export default class DatabaseRoutes {
|
||||||
pos: getPosType(),
|
pos: getPosType(),
|
||||||
zoom: { type: DataTypes.INTEGER.UNSIGNED, allowNull: false, validate: { min: 1, max: 20 } },
|
zoom: { type: DataTypes.INTEGER.UNSIGNED, allowNull: false, validate: { min: 1, max: 20 } },
|
||||||
idx: { type: DataTypes.INTEGER.UNSIGNED, allowNull: false },
|
idx: { type: DataTypes.INTEGER.UNSIGNED, allowNull: false },
|
||||||
ele: { type: DataTypes.INTEGER, allowNull: true }
|
ele: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
allowNull: true,
|
||||||
|
set: function(this: RoutePointModel, v: number | null) {
|
||||||
|
// Round number to avoid integer column error in Postgres
|
||||||
|
this.setDataValue("ele", v != null ? Math.round(v) : v);
|
||||||
|
}
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
sequelize: this._db._conn,
|
sequelize: this._db._conn,
|
||||||
indexes: [
|
indexes: [
|
||||||
|
|
Ładowanie…
Reference in New Issue