Skip to content

Commit

Permalink
Subo caso para boolean (falla)
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoefe committed Dec 6, 2016
1 parent 371abf7 commit e0a0376
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/txt-to-sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var types = [
{adapt:adaptPlain, pad:padRight, dataPattern:/^-?[0-9]+\.?[0-9]*$/, useLength:true}, // numeric
{adapt:adaptPlain, pad:padRight, dataPattern:/^-?[0-9]+\.?[0-9]*([eE]-?[0-9]+)?$/}, // double precision
{adapt:adaptText , pad:padLeft , dataPattern:/.?/, useLength:true, isTextColumn:true}, // character varying
{adapt:adaptPlain, pad:padRight, dataPattern:/^[yntf01]?/i} // boolean
{adapt:adaptPlain, pad:padRight, dataPattern:/^([yntf01])?/i}, // boolean
];

function mapTypes(typeNames) {
Expand Down
22 changes: 22 additions & 0 deletions test/fixtures/booleans.result.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
columns:
- name: b1
type: boolean
inPrimaryKey: false
maxLength: 1
maxScale: 0
hasNullValues: false
hasCientificNotation: null
- name: b2
type: boolean
inPrimaryKey: false
maxLength: 1
maxScale: 0
hasNullValues: false
hasCientificNotation: null
- name: b3
type: boolean
inPrimaryKey: false
maxLength: 1
maxScale: 0
hasNullValues: false
hasCientificNotation: null
11 changes: 11 additions & 0 deletions test/fixtures/booleans.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
create table "booleans" (
"text-field" character varying(5),
"int-field" integer,
"num-field" numeric(8,6),
"big" bigint,
"double" double precision
);

insert into "booleans" ("text-field", "int-field", "num-field", "big", "double") values
('hello', 1, 3.141592, 1234567890, 1.12e-101),
(null, null, null, 0, 0.0);
3 changes: 3 additions & 0 deletions test/fixtures/booleans.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
b1;b2;b3
t;1;y
f;0;n
1 change: 1 addition & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ describe("fixtures", function(){
{name:'insert-limit'},
{name:'mssql-insert-limit'}, // compactInsertLimit should be ignored (#24)
{name:'insert-limit2'},
{skip:true, name:'booleans'},
].forEach(function(fixture){
if(fixture.skip) {
it.skip("fixture: "+fixture.name);
Expand Down
2 changes: 1 addition & 1 deletion web/txt-to-sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var types = [
{adapt:adaptPlain, pad:padRight, dataPattern:/^-?[0-9]+\.?[0-9]*$/, useLength:true}, // numeric
{adapt:adaptPlain, pad:padRight, dataPattern:/^-?[0-9]+\.?[0-9]*([eE]-?[0-9]+)?$/}, // double precision
{adapt:adaptText , pad:padLeft , dataPattern:/.?/, useLength:true, isTextColumn:true}, // character varying
{adapt:adaptPlain, pad:padRight, dataPattern:/^[yntf01]?/i} // boolean
{adapt:adaptPlain, pad:padRight, dataPattern:/^([yntf01])?/i}, // boolean
];

function mapTypes(typeNames) {
Expand Down

0 comments on commit e0a0376

Please sign in to comment.