File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -126,13 +126,10 @@ Table.prototype.addColumn = function(col, options) {
126126} ;
127127
128128Table . prototype . hasColumn = function ( col ) {
129- col = this . createColumn ( col ) ;
130-
131- var cols = this . columns . filter ( function ( column ) {
132- return column . property === col . property || column . name === col . name ;
129+ var columnName = col instanceof Column ? col . name : col ;
130+ return this . columns . some ( function ( column ) {
131+ return column . property === columnName || column . name === columnName ;
133132 } ) ;
134-
135- return cols . length > 0 ;
136133} ;
137134
138135Table . prototype . getColumn =
Original file line number Diff line number Diff line change @@ -167,6 +167,19 @@ test('hasColumn', function() {
167167 assert . equal ( table . hasColumn ( 'baz' ) , true ) ;
168168} ) ;
169169
170+ test ( 'hasColumn with user-defined column property' , function ( ) {
171+ var table = Table . define ( {
172+ name : 'blah' ,
173+ columns : [ {
174+ name : 'id' ,
175+ property : 'theId'
176+ } , { name : 'foo' } ]
177+ } ) ;
178+
179+ assert . equal ( table . hasColumn ( 'id' ) , true ) ;
180+ assert . equal ( table . hasColumn ( 'theId' ) , true ) ;
181+ } ) ;
182+
170183test ( 'the column "from" does not overwrite the from method' , function ( ) {
171184 var table = Table . define ( { name : 'foo' , columns : [ ] } ) ;
172185 table . addColumn ( 'from' ) ;
You can’t perform that action at this time.
0 commit comments