help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] [PATCH 1/3] dbi: Correct >>#columnNames selector


From: Holger Hans Peter Freyther
Subject: [Help-smalltalk] [PATCH 1/3] dbi: Correct >>#columnNames selector
Date: Sun, 2 Aug 2015 16:42:15 +0200

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  <address@hidden>

        * Table.st: Fix >>#columnNames to return the column
        names and not the table name.

2015-08-01  Holger Hans Peter Freyther  <address@hidden>

        * 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  <address@hidden>
+
+       * SQLiteTests.st: Add SQLiteTableTestCase class and
+       >>#testTableColumns. Add the testTableColumns to the
+       SQLiteTestSuite class >> #suite selector.
+
 2013-08-25  Holger Hans Peter Freyther  <address@hidden>
 
        * 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  <address@hidden>
+
+       * Table.st: Fix >>#columnNames to return the column
+       names and not the table name.
+
 2013-12-17  Holger Hans Peter Freyther  <address@hidden>
 
        * 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]