The code attempted to go through the columns and then collect their name, instead it collected the name of the table for each column.
DBI doesn't have unit tests by itself so I am using the SQLite implementation to run the test. 2015-08-01 Holger Hans Peter Freyther <hol...@freyther.de> * Table.st: Fix >>#columnNames to return the column names and not the table name. 2015-08-01 Holger Hans Peter Freyther <hol...@freyther.de> * SQLiteTests.st: Add SQLiteTableTestCase class and >>#testTableColumns. Add the testTableColumns to the SQLiteTestSuite class >> #suite selector. --- packages/dbd-sqlite/ChangeLog | 6 ++++++ packages/dbd-sqlite/SQLiteTests.st | 12 ++++++++++++ packages/dbi/ChangeLog | 5 +++++ packages/dbi/Table.st | 2 +- 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/packages/dbd-sqlite/ChangeLog b/packages/dbd-sqlite/ChangeLog index ba68e09..af65408 100644 --- a/packages/dbd-sqlite/ChangeLog +++ b/packages/dbd-sqlite/ChangeLog @@ -1,3 +1,9 @@ +2015-08-01 Holger Hans Peter Freyther <hol...@freyther.de> + + * SQLiteTests.st: Add SQLiteTableTestCase class and + >>#testTableColumns. Add the testTableColumns to the + SQLiteTestSuite class >> #suite selector. + 2013-08-25 Holger Hans Peter Freyther <hol...@freyther.de> * Connection.st: Add >>#beginTransaction. diff --git a/packages/dbd-sqlite/SQLiteTests.st b/packages/dbd-sqlite/SQLiteTests.st index 7e89211..a9e773d 100644 --- a/packages/dbd-sqlite/SQLiteTests.st +++ b/packages/dbd-sqlite/SQLiteTests.st @@ -225,6 +225,16 @@ SQLiteBaseTest subclass: SQLitePreparedStatementTestCase [ ] ] +SQLiteBaseTest subclass: SQLiteTableTestCase [ + + testTableColumns [ + | columnNames | + "columnNames returning wrong value" + columnNames := (connection tableAt: 'test') columnNames. + self assert: columnNames asArray equals: #('int_field' 'string_field' 'double_field'). + ] +] + TestSuite subclass: SQLiteTestSuite [ SQLiteTestSuite class >> suite [ ^super new initialize @@ -248,5 +258,7 @@ TestSuite subclass: SQLiteTestSuite [ self addTest: (SQLitePreparedStatementTestCase selector: #testExecute). self addTest: (SQLitePreparedStatementTestCase selector: #testExecuteWithAll). self addTest: (SQLitePreparedStatementTestCase selector: #testExecuteWithAllNamed). + + self addTest: (SQLiteTableTestCase selector: #testTableColumns). ] ] diff --git a/packages/dbi/ChangeLog b/packages/dbi/ChangeLog index 815bafd..229c518 100644 --- a/packages/dbi/ChangeLog +++ b/packages/dbi/ChangeLog @@ -1,3 +1,8 @@ +2015-08-01 Holger Hans Peter Freyther <hol...@freyther.de> + + * Table.st: Fix >>#columnNames to return the column + names and not the table name. + 2013-12-17 Holger Hans Peter Freyther <hol...@freyther.de> * Connection.st: Initialize Drivers from >>#initialize. diff --git a/packages/dbi/Table.st b/packages/dbi/Table.st index 0da7f11..0188d34 100644 --- a/packages/dbi/Table.st +++ b/packages/dbi/Table.st @@ -69,7 +69,7 @@ ROE.RASQLRelation subclass: Table [ "Answer an array of column names in order (abstract)." <category: 'accessing'> - ^self columnsArray collect: [:each | self name] + ^self columnsArray collect: [:each | each name] ] columnAt: aIndex [ -- 2.3.5 _______________________________________________ help-smalltalk mailing list help-smalltalk@gnu.org https://lists.gnu.org/mailman/listinfo/help-smalltalk