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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Holger Freyther
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  <[hidden email]>

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

2015-08-01  Holger Hans Peter Freyther  <[hidden email]>

        * 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  <[hidden email]>
+
+ * SQLiteTests.st: Add SQLiteTableTestCase class and
+ >>#testTableColumns. Add the testTableColumns to the
+ SQLiteTestSuite class >> #suite selector.
+
 2013-08-25  Holger Hans Peter Freyther  <[hidden email]>
 
  * 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  <[hidden email]>
+
+ * Table.st: Fix >>#columnNames to return the column
+ names and not the table name.
+
 2013-12-17  Holger Hans Peter Freyther  <[hidden email]>
 
  * 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
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

[PATCH 2/3] libgst: Fix the cint.c build on XNU/Darwin

Holger Freyther
fdatasync appears to be available when linking but there is
no declaration in XNU. Move from checking the function to
checking the declaration.

Fixes:

cint.c:663:35: error: use of undeclared identifier 'fdatasync'
  _gst_define_cfunc ("fdatasync", fdatasync);
                                  ^

2015-05-21  Holger Hans Peter Freyther  <[hidden email]>

        * configure.ac: Move from AC_CHECK_FUNCS_ONCE to AC_CHECK_DECLS
        for fdatasync.

2015-05-21  Holger Hans Peter Freyther  <[hidden email]>

        * cint.c: Change to use #if instead of #ifdef and update
        the macro to change for.
---
 ChangeLog        | 5 +++++
 configure.ac     | 3 ++-
 libgst/ChangeLog | 5 +++++
 libgst/cint.c    | 2 +-
 4 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b88cfe7..2875294 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-05-21  Holger Hans Peter Freyther  <[hidden email]>
+
+ * configure.ac: Move from AC_CHECK_FUNCS_ONCE to AC_CHECK_DECLS
+ for fdatasync.
+
 2015-01-25  Holger Hans Peter Freyther  <[hidden email]>
 
  * scripts/Remote.st: Document -I and --no-line-numbers.
diff --git a/configure.ac b/configure.ac
index bfd09a4..2102214 100644
--- a/configure.ac
+++ b/configure.ac
@@ -359,7 +359,7 @@ AC_REPLACE_FUNCS(putenv strdup strerror strsignal mkstemp getpagesize \
         lrint trunc strsep strpbrk symlink mkdtemp)
 AC_CHECK_FUNCS_ONCE(gethostname memcpy memmove sighold uname usleep lstat \
  grantpt popen getrusage gettimeofday fork strchr utimes utime readlink \
- sigsetmask alarm select mprotect madvise waitpid accept4 fdatasync \
+ sigsetmask alarm select mprotect madvise waitpid accept4 \
  setsid spawnl pread pwrite _NSGetExecutablePath _NSGetEnviron \
  chown getgrnam getpwnam endgrent endpwent setgroupent setpassent)
 
@@ -371,6 +371,7 @@ fi
 
 dnl FreeBSD does provide an environ but it is not declared in the headers
 AC_CHECK_DECLS([environ])
+AC_CHECK_DECLS([fdatasync], [], [], [[#include <unistd.h>]])
 
 AC_SEARCH_LIBS([nanosleep], [rt])
 if test "$ac_cv_search_nanosleep" != no; then
diff --git a/libgst/ChangeLog b/libgst/ChangeLog
index 6724338..cc0fdb1 100644
--- a/libgst/ChangeLog
+++ b/libgst/ChangeLog
@@ -1,3 +1,8 @@
+2015-05-21  Holger Hans Peter Freyther  <[hidden email]>
+
+ * cint.c: Change to use #if instead of #ifdef and update
+ the macro to change for.
+
 2015-04-17  Holger Hans Peter Freyther  <[hidden email]>
 
  * sysdep/posix/timer.c: Fix handling small sleeping
diff --git a/libgst/cint.c b/libgst/cint.c
index 510cc46..fdb6ce3 100644
--- a/libgst/cint.c
+++ b/libgst/cint.c
@@ -659,7 +659,7 @@ _gst_init_cfuncs (void)
   _gst_define_cfunc ("mkdtemp", my_mkdtemp);
   _gst_define_cfunc ("getCurDirName", _gst_get_cur_dir_name);
   _gst_define_cfunc ("fsync", fsync);
-#ifdef HAVE_FDATASYNC
+#if HAVE_DECL_FDATASYNC
   _gst_define_cfunc ("fdatasync", fdatasync);
 #else
   _gst_define_cfunc ("fdatasync", fsync);
--
2.3.5


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

[PATCH 3/3] libgst: Address clang compiler warning

Holger Freyther
In reply to this post by Holger Freyther
Use if () {} else {} instead of an else if() {} that would
always be true. First we compare cur_time to < next_poll_ms
so in the else branch it must be >=.

events.c:218:20: warning: variable 'ms' is used uninitialized whenever 'if' condition is false
      [-Wsometimes-uninitialized]
          else if (cur_time >= next_poll_ms)
                   ^~~~~~~~~~~~~~~~~~~~~~~~
events.c:233:11: note: uninitialized use occurs here
      if (ms == INFINITE)
          ^~
events.c:218:16: note: remove the 'if' if its condition is always true
          else if (cur_time >= next_poll_ms)
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
events.c:207:18: note: initialize the variable 'ms' to silence this warning
      unsigned ms;
                 ^
                  = 0

2015-08-02  Holger Hans Peter Freyther  <[hidden email]>

        * events.c: Use else instead of else if in
        poll_timer_thread.
---
 libgst/ChangeLog | 5 +++++
 libgst/events.c  | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/libgst/ChangeLog b/libgst/ChangeLog
index cc0fdb1..cbb26c6 100644
--- a/libgst/ChangeLog
+++ b/libgst/ChangeLog
@@ -1,3 +1,8 @@
+2015-08-02  Holger Hans Peter Freyther  <[hidden email]>
+
+ * events.c: Use else instead of else if in
+ poll_timer_thread.
+
 2015-05-21  Holger Hans Peter Freyther  <[hidden email]>
 
  * cint.c: Change to use #if instead of #ifdef and update
diff --git a/libgst/events.c b/libgst/events.c
index 2333672..57b33f4 100644
--- a/libgst/events.c
+++ b/libgst/events.c
@@ -215,7 +215,7 @@ poll_timer_thread (void *unused)
           cur_time = _gst_get_milli_time ();
           if (cur_time < next_poll_ms)
             ms = MIN(0, next_poll_ms - cur_time);
-          else if (cur_time >= next_poll_ms)
+          else
             {
               ms = EVENT_LOOP_POLL_INTERVAL;
               next_poll_ms = cur_time + ms;
--
2.3.5


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 1/3] dbi: Correct >>#columnNames selector

fifacome56
In reply to this post by Holger Freyther
who had Jorge Valdivia sent off after the final whistle and are still without a win at the Centenario, where they have registered a solitary draw in eight visits.




------------------------------------------
http://www.fifachampion.com/
http://www.utfifa.co/