Skip to content

Commit 87b9fdc

Browse files
committed
Assume string as default type
1 parent f5aecfc commit 87b9fdc

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

lib/actions/insert.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const cosql = require('co-mssql');
55

66
let pstmt;
77

8-
const VARS_REGEXP = /@([\w_$][\d\w_$]*:(string|boolean|date|number|bigint|float|real|money))/g;
8+
const VARS_REGEXP = /@([\w_$][\d\w_$]*(:(string|boolean|date|number|bigint|float|real|money))?)/g;
99

1010
/**
1111
* This function will be called during component intialization
@@ -31,6 +31,7 @@ function init(cfg) {
3131
const [placeholder, type] = tuple.split(':');
3232
const name = placeholder.substr(1);
3333
switch (type) {
34+
case undefined:
3435
case 'string':
3536
pstmt.input(name, cosql.NVarChar);
3637
break;

spec/metadata.spec.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,52 @@ describe('Metadata test', () => {
9292
});
9393
});
9494

95+
it('should assume default metadata as stirng', (done) => {
96+
insert.getMetaModel({
97+
query: 'INSERT INTO Test2.dbo.Tweets '
98+
+ '(Lang, Retweeted, Favorited, "Text", id, CreatedAt, Username, ScreenName) '
99+
+ 'VALUES (@lang, @retweeted:float, @money:money, @favorited:boolean, '
100+
+ '@text, @id:bigint, @created_at:date, @username, @screenname)'
101+
}, (err, result) => {
102+
expect(err).to.be.null;
103+
expect(result).to.deep.equal({
104+
in: {
105+
properties: {
106+
created_at: {
107+
type: 'string'
108+
},
109+
favorited: {
110+
type: 'string'
111+
},
112+
id: {
113+
type: 'number'
114+
},
115+
lang: {
116+
type: 'string'
117+
},
118+
money: {
119+
type: 'number'
120+
},
121+
retweeted: {
122+
type: 'number'
123+
},
124+
screenname: {
125+
type: 'string'
126+
},
127+
text: {
128+
type: 'string'
129+
},
130+
username: {
131+
type: 'string'
132+
}
133+
},
134+
type: 'object'
135+
},
136+
out: {}
137+
}
138+
);
139+
done();
140+
});
141+
});
95142

96143
});

0 commit comments

Comments
 (0)