Skip to content

Commit

Permalink
Elimino comillas innecesarias y agrego comentarios
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoefe committed Oct 18, 2016
1 parent 48d1930 commit f96e037
Show file tree
Hide file tree
Showing 15 changed files with 63 additions and 59 deletions.
4 changes: 2 additions & 2 deletions bin/txt-to-sql-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ cmdParams.fast = program.fast;
cmdParams.exportDefaults = program.exportDefaults;

// numero de lineas a leer para analizar entrada
var bufferingThreeshold = 50;
var fastBufferingThreshold = 50;

function collectExistentFiles(files) {
var existentFiles = [];
Expand Down Expand Up @@ -179,7 +179,7 @@ function doFast(params, inputBase) {
outStream = fsSync.createWriteStream(inputBase+'.sql', {encoding:'utf8'});
info.lines = [];
// maximo de lineas para utilizar procesamiento standard
info.fastMaxLines = bufferingThreeshold;
info.fastMaxLines = fastBufferingThreshold;
rl = readline.createInterface({
input: inStream,
terminal: false
Expand Down
6 changes: 4 additions & 2 deletions lib/txt-to-sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,10 @@ function determinePrimaryKey(info) {
}
return false;
});
if(haveCustomKeys.length && columnsInKey.length===0) {
if(haveCustomKeys.length>0 && columnsInKey.length===0) {
warnings.push("includePrimaryKey is on but no columns were selected");
}
// no custom keys, using all fields
if(columnsInKey.length===0) {
columnsInKey = info.columnsInfo.map(function(col, colIndex) { return colIndex; } );
}
Expand Down Expand Up @@ -430,11 +431,12 @@ function determinePrimaryKey(info) {
}catch(err){
if(err.message!=="haveNullColumns") { throw err; }
}
if(columnsInKey.length && (! info.primaryKey || ! info.primaryKey.length)) {
if(columnsInKey.length>0 && (! info.primaryKey || ! info.primaryKey.length>0)) {
var failingColumns = columnsInKey.map(function(col) {
return info.columnsInfo[col].name;
});
warnings.push('requested columns ('+failingColumns.join(', ')+') failed to be a PrimaryKey');
// we honor user's desire anyway
if(info.opts.includePrimaryKey) { info.primaryKey = failingColumns; }
}
if(warnings.length) { info.warnings = warnings; }
Expand Down
6 changes: 3 additions & 3 deletions test/errors/include-pk-columns-no-pk.param.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ tableName: t1
opts:
includePrimaryKey: true
columns:
- name: 'text-field'
- name: text-field
type: character varying
inPrimaryKey: true
maxLength: 5
maxScale: null
hasNullValues: false
hasCientificNotation: null
- name: 'int-field'
- name: int-field
type: integer
inPrimaryKey: true
maxLength: 1
maxScale: 0
hasNullValues: false
hasCientificNotation: null
- name: 'num""1""'
- name: num""1""
type: numeric
inPrimaryKey: false
maxLength: 1
Expand Down
6 changes: 3 additions & 3 deletions test/errors/include-pk-without-pk-columns.param.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
tableName: t1
opts:
columns:
- name: '"text-field"'
- name: text-field
type: character varying
inPrimaryKey: false
maxLength: 5
maxScale: null
hasNullValues: false
hasCientificNotation: null
- name: '"int-field"'
- name: int-field
type: integer
inPrimaryKey: false
maxLength: 1
maxScale: 0
hasNullValues: false
hasCientificNotation: null
- name: '"num""1"""'
- name: num""1""
type: numeric
inPrimaryKey: false
maxLength: 1
Expand Down
10 changes: 5 additions & 5 deletions test/fixtures/column-names.result.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,35 @@ opts:
- name: mi-big
- name: mi-double
columns:
- name: 'mi-text'
- name: mi-text
type: character varying
inPrimaryKey: false
maxLength: 5
maxScale: null
hasNullValues: true
hasCientificNotation: null
- name: 'mi-int'
- name: mi-int
type: integer
inPrimaryKey: false
maxLength: 1
maxScale: 0
hasNullValues: true
hasCientificNotation: null
- name: 'mi-num'
- name: mi-num
type: numeric
inPrimaryKey: false
maxLength: 1
maxScale: 6
hasNullValues: true
hasCientificNotation: null
- name: 'mi-big'
- name: mi-big
type: bigint
inPrimaryKey: false
maxLength: 10
maxScale: 0
hasNullValues: false
hasCientificNotation: null
- name: 'mi-double'
- name: mi-double
type: double precision
inPrimaryKey: false
maxLength: 1
Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/comma-align-with-max.result.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ opts:
columnAlignedCommas: true
columnAlignedMaxWidth: 14
columns:
- name: 'text-field'
- name: text-field
type: character varying
inPrimaryKey: true
maxLength: 15
maxScale: null
hasNullValues: false
hasCientificNotation: null
- name: 'int-field'
- name: int-field
type: integer
inPrimaryKey: true
maxLength: 2
maxScale: 0
hasNullValues: false
hasCientificNotation: null
- name: 'numerico-el-1'
- name: numerico-el-1
type: numeric
inPrimaryKey: false
maxLength: 2
Expand Down
10 changes: 5 additions & 5 deletions test/fixtures/example-one.result.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
columns:
- name: 'text-field'
- name: text-field
type: character varying
inPrimaryKey: false
maxLength: 5
maxScale: null
hasNullValues: true
hasCientificNotation: null
- name: 'int-field'
- name: int-field
type: integer
inPrimaryKey: false
maxLength: 1
maxScale: 0
hasNullValues: true
hasCientificNotation: null
- name: 'num-field'
- name: num-field
type: numeric
inPrimaryKey: false
maxLength: 1
maxScale: 6
hasNullValues: true
hasCientificNotation: null
- name: 'big'
- name: big
type: bigint
inPrimaryKey: false
maxLength: 10
maxScale: 0
hasNullValues: false
hasCientificNotation: null
- name: 'double'
- name: double
type: double precision
inPrimaryKey: false
maxLength: 1
Expand Down
12 changes: 6 additions & 6 deletions test/fixtures/fields-lcalpha.result.yaml
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
opts:
columnNamesFormat: lowercased_alpha
columns:
- name: 'conene'
- name: conene
type: character varying
inPrimaryKey: false
maxLength: 13
maxScale: null
hasNullValues: true
hasCientificNotation: null
- name: 'esdrujulo'
- name: esdrujulo
type: integer
inPrimaryKey: false
maxLength: 1
maxScale: 0
hasNullValues: true
hasCientificNotation: null
- name: 'masdias'
- name: masdias
type: numeric
inPrimaryKey: false
maxLength: 1
maxScale: 6
hasNullValues: true
hasCientificNotation: null
- name: 'faltanaeeiiuoooo'
- name: faltanaeeiiuoooo
type: bigint
inPrimaryKey: false
maxLength: 10
maxScale: 0
hasNullValues: false
hasCientificNotation: null
- name: '_1numeroyacento'
- name: _1numeroyacento
type: double precision
inPrimaryKey: false
maxLength: 1
maxScale: 7
hasNullValues: false
hasCientificNotation: true
- name: 'maas'
- name: maas
type: integer
inPrimaryKey: false
maxLength: 0
Expand Down
10 changes: 5 additions & 5 deletions test/fixtures/fields-lcnames.result.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
columns:
- name: 'text-field'
- name: text-field
type: character varying
inPrimaryKey: false
maxLength: 5
maxScale: null
hasNullValues: true
hasCientificNotation: null
- name: 'int-field'
- name: int-field
type: integer
inPrimaryKey: false
maxLength: 1
maxScale: 0
hasNullValues: true
hasCientificNotation: null
- name: 'num-field'
- name: num-field
type: numeric
inPrimaryKey: false
maxLength: 1
maxScale: 6
hasNullValues: true
hasCientificNotation: null
- name: 'big'
- name: big
type: bigint
inPrimaryKey: false
maxLength: 10
maxScale: 0
hasNullValues: false
hasCientificNotation: null
- name: 'double'
- name: double
type: double precision
inPrimaryKey: false
maxLength: 1
Expand Down
10 changes: 5 additions & 5 deletions test/fixtures/mysql-example-one.result.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@ opts:
columnNamesFormat: lowercased_names
outputEngine: mysql
columns:
- name: 'text-field'
- name: text-field
type: varchar
inPrimaryKey: false
maxLength: 5
maxScale: null
hasNullValues: true
hasCientificNotation: null
- name: 'int-field'
- name: int-field
type: integer
inPrimaryKey: false
maxLength: 1
maxScale: 0
hasNullValues: true
hasCientificNotation: null
- name: 'num-field'
- name: num-field
type: numeric
inPrimaryKey: false
maxLength: 1
maxScale: 6
hasNullValues: true
hasCientificNotation: null
- name: 'big'
- name: big
type: bigint
inPrimaryKey: false
maxLength: 10
maxScale: 0
hasNullValues: false
hasCientificNotation: null
- name: 'double'
- name: double
type: double precision
inPrimaryKey: false
maxLength: 1
Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/pk-complex-all.result.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
columns:
- name: 'text-field'
- name: text-field
type: character varying
inPrimaryKey: true
maxLength: 5
maxScale: null
hasNullValues: false
hasCientificNotation: null
- name: 'int-field'
- name: int-field
type: integer
inPrimaryKey: true
maxLength: 1
maxScale: 0
hasNullValues: false
hasCientificNotation: null
- name: 'num"1"'
- name: num"1"
type: numeric
inPrimaryKey: true
maxLength: 1
Expand Down
10 changes: 5 additions & 5 deletions test/fixtures/separator.result.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
columns:
- name: 'text-field'
- name: text-field
type: character varying
inPrimaryKey: false
maxLength: 5
maxScale: null
hasNullValues: true
hasCientificNotation: null
- name: 'int-field'
- name: int-field
type: integer
inPrimaryKey: false
maxLength: 1
maxScale: 0
hasNullValues: true
hasCientificNotation: null
- name: 'num-field'
- name: num-field
type: numeric
inPrimaryKey: false
maxLength: 1
maxScale: 6
hasNullValues: true
hasCientificNotation: null
- name: 'big'
- name: big
type: bigint
inPrimaryKey: false
maxLength: 10
maxScale: 0
hasNullValues: false
hasCientificNotation: null
- name: 'double'
- name: double
type: double precision
inPrimaryKey: false
maxLength: 1
Expand Down
Loading

0 comments on commit f96e037

Please sign in to comment.