working on SqlServer spatial types;

This commit is contained in:
Zotov Dmitry 2018-03-29 20:39:41 +05:00
parent 5abe3579a7
commit bbaf1abdf4
11 changed files with 62 additions and 3 deletions

View File

@ -3,7 +3,7 @@ services:
# mysql
mysql:
image: "mysql:5.5"
image: "mysql:5.7.10"
container_name: "typeorm-mysql"
ports:
- "3306:3306"

View File

@ -47,6 +47,11 @@ export interface Driver {
*/
dataTypeDefaults: DataTypeDefaults;
/**
* Gets list of spatial column data types.
*/
spatialTypes: ColumnType[];
/**
* Gets list of column data types that support length by a driver.
*/

View File

@ -59,6 +59,11 @@ export class MongoDriver implements Driver {
*/
supportedDataTypes: ColumnType[] = [];
/**
* Gets list of spatial column data types.
*/
spatialTypes: ColumnType[] = [];
/**
* Gets list of column data types that support length by a driver.
*/

View File

@ -118,6 +118,9 @@ export class MysqlDriver implements Driver {
"geometrycollection"
];
/**
* Gets list of spatial column data types.
*/
spatialTypes: ColumnType[] = [
"geometry",
"point",

View File

@ -110,6 +110,11 @@ export class OracleDriver implements Driver {
"urowid"
];
/**
* Gets list of spatial column data types.
*/
spatialTypes: ColumnType[] = [];
/**
* Gets list of column data types that support length by a driver.
*/

View File

@ -147,6 +147,11 @@ export class PostgresDriver implements Driver {
"daterange"
];
/**
* Gets list of spatial column data types.
*/
spatialTypes: ColumnType[] = [];
/**
* Gets list of column data types that support length by a driver.
*/

View File

@ -121,6 +121,11 @@ export abstract class AbstractSqliteDriver implements Driver {
"clob"
];
/**
* Gets list of spatial column data types.
*/
spatialTypes: ColumnType[] = [];
/**
* Gets list of column data types that support precision by a driver.
*/

View File

@ -111,7 +111,17 @@ export class SqlServerDriver implements Driver {
"table",
"timestamp",
"uniqueidentifier",
"xml"
"xml",
"geometry",
"geography"
];
/**
* Gets list of spatial column data types.
*/
spatialTypes: ColumnType[] = [
"geometry",
"geography"
];
/**

View File

@ -136,6 +136,7 @@ export type SimpleColumnType =
|"circle" // postgres
|"path" // postgres
|"polygon" // postgres, mysql
|"geography" // mssql
|"geometry" // mysql
|"linestring" // mysql
|"multipoint" // mysql

View File

@ -6,7 +6,7 @@ import {PostWithOptions} from "./entity/PostWithOptions";
import {PostWithoutTypes} from "./entity/PostWithoutTypes";
import {DateUtils} from "../../../../../src/util/DateUtils";
describe("database schema > column types > mssql", () => {
describe.skip("database schema > column types > mssql", () => { // https://github.com/tediousjs/tedious/issues/722
let connections: Connection[];
before(async () => {
@ -61,6 +61,9 @@ describe("database schema > column types > mssql", () => {
post.timeObj = new Date();
post.time = "15:30:00";
post.datetimeoffset = new Date();
post.geometry1 = "LINESTRING (100 100, 20 180, 180 180)";
post.geometry2 = "POLYGON ((0 0, 150 0, 150 150, 0 150, 0 0))";
post.geometry3 = "GEOMETRYCOLLECTION (POINT (4 0), LINESTRING (4 2, 5 3), POLYGON ((0 0, 3 0, 3 3, 0 3, 0 0), (1 1, 1 2, 2 2, 2 1, 1 1)))";
post.simpleArray = ["A", "B", "C"];
post.simpleJson = { param: "VALUE" };
await postRepository.save(post);
@ -97,6 +100,9 @@ describe("database schema > column types > mssql", () => {
// loadedPost.datetime.getTime().should.be.equal(post.datetime.getTime());
// loadedPost.datetime2.getTime().should.be.equal(post.datetime2.getTime());
// loadedPost.datetimeoffset.getTime().should.be.equal(post.datetimeoffset.getTime());
loadedPost.geometry1.should.be.equal(post.geometry1);
loadedPost.geometry2.should.be.equal(post.geometry2);
loadedPost.geometry3.should.be.equal(post.geometry3);
loadedPost.smalldatetime.getTime().should.be.equal(post.smalldatetime.getTime());
loadedPost.timeObj.should.be.equal(DateUtils.mixedTimeToString(post.timeObj));
loadedPost.time.should.be.equal(post.time);
@ -140,6 +146,7 @@ describe("database schema > column types > mssql", () => {
table!.findColumnByName("time")!.type.should.be.equal("time");
table!.findColumnByName("timeObj")!.type.should.be.equal("time");
table!.findColumnByName("datetimeoffset")!.type.should.be.equal("datetimeoffset");
table!.findColumnByName("geometry1")!.type.should.be.equal("geometry");
table!.findColumnByName("simpleArray")!.type.should.be.equal("ntext");
table!.findColumnByName("simpleJson")!.type.should.be.equal("ntext");

View File

@ -113,6 +113,19 @@ export class Post {
@Column("datetimeoffset")
datetimeoffset: Date;
// -------------------------------------------------------------------------
// Spatial Types
// -------------------------------------------------------------------------
@Column("geometry")
geometry1: string;
@Column("geometry")
geometry2: string;
@Column("geometry")
geometry3: string;
// -------------------------------------------------------------------------
// TypeOrm Specific Types
// -------------------------------------------------------------------------