Author: wyoung
Date: Wed Dec 26 23:00:20 2007
New Revision: 2020

URL: http://svn.gna.org/viewcvs/mysqlpp?rev=2020&view=rev
Log:
- Changed the 'price' column in the test stock table to a DECIMAL type
  from DOUBLE for better coverage of types, and because it's more
  appropriate to a money column.
- Expanded fieldinf example's outputs and refined column widths to
  better do type testing from above.

Modified:
    trunk/bmark.txt
    trunk/examples/fieldinf.cpp
    trunk/examples/printdata.cpp
    trunk/examples/printdata.h
    trunk/examples/resetdb.cpp

Modified: trunk/bmark.txt
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/bmark.txt?rev=2020&r1=2019&r2=2020&view=diff
==============================================================================
--- trunk/bmark.txt (original)
+++ trunk/bmark.txt Wed Dec 26 23:00:20 2007
@@ -23,7 +23,7 @@
 Nürnberger Brats              97        1.5       8.79      2005-03-10
 Pickle Relish                  87        1.5       1.75      1998-09-04
 Hot Mustard                    73        0.95      0.97      1998-05-25
-Hotdog Buns                    65        1.1       1.1       1998-04-23
+Hotdog Buns                    65        1.1       1.10      1998-04-23
 ================ END simple2 OUTPUT ================
 
 ---------------- BEGIN simple3 OUTPUT ----------------
@@ -32,7 +32,7 @@
 Nürnberger Brats              97        1.5       8.79      2005-03-10
 Pickle Relish                  87        1.5       1.75      1998-09-04
 Hot Mustard                    73        0.95      0.97      1998-05-25
-Hotdog Buns                    65        1.1       1.1       1998-04-23
+Hotdog Buns                    65        1.1       1.10      1998-04-23
 ================ END simple3 OUTPUT ================
 
 ---------------- BEGIN store_if OUTPUT ----------------
@@ -141,20 +141,20 @@
  item                    char(30)              NO                         
  num                     bigint(20)            NO                         
  weight                  double                NO                         
- price                   double                NO                         
+ price                   decimal(6,2)          NO                         
  sdate                   date                  NO                         
  description             mediumtext            YES        NULL            
 ================ END dbinfo OUTPUT ================
 
 ---------------- BEGIN fieldinf OUTPUT ----------------
-Field   SQL Type       Equivalent C++ Type                                     
 
-======= ============== 
======================================================== 
-item    CHAR NOT NULL  n/a                                                     
 
-num     BIGINT NOT NULLn/a                                                     
 
-weight  DOUBLE NOT NULLn/a                                                     
 
-price   DOUBLE NOT NULLn/a                                                     
 
-sdate   DATE NOT NULL  n/a                                                     
 
-descriptionBLOB NULL      n/a                                                  
    
+Field       SQL Type              Equivalent C++ Type                          
 
+=========== ===================== 
============================================= 
+item        CHAR NOT NULL (25)    n/a                                          
 
+num         BIGINT NOT NULL (11)  n/a                                          
 
+weight      DOUBLE NOT NULL (8)   n/a                                          
 
+price       CHAR NOT NULL (25)    n/a                                          
 
+sdate       DATE NOT NULL (15)    n/a                                          
 
+description BLOB NULL (49)        n/a                                          
 
 
 SQL type of 'item' field most closely resembles the C++ string type.
 SQL type of 'description' field resembles a nullable variant of the C++ string 
type.

Modified: trunk/examples/fieldinf.cpp
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/examples/fieldinf.cpp?rev=2020&r1=2019&r2=2020&view=diff
==============================================================================
--- trunk/examples/fieldinf.cpp (original)
+++ trunk/examples/fieldinf.cpp Wed Dec 26 23:00:20 2007
@@ -57,7 +57,7 @@
                mysqlpp::StoreQueryResult res = query.store();
 
                // Show info about each field in that table
-               char widths[] = { 8, 15, 57 };
+               char widths[] = { 12, 22, 46 };
                cout.setf(ios::left);
                cout << setw(widths[0]) << "Field" <<
                                setw(widths[1]) << "SQL Type" <<
@@ -72,8 +72,11 @@
                        // Suppress C++ type name outputs when run under dtest,
                        // as they're system-specific.
                        const char* cname = dtest_mode ? "n/a" : 
res.field_type(i).name();
+                       mysqlpp::FieldTypes::value_type ft = res.field_type(i);
+                       ostringstream os;
+                       os << ft.sql_name() << " (" << ft.id() << ')';
                        cout << setw(widths[0]) << res.field_name(i).c_str() <<
-                                       setw(widths[1]) << 
res.field_type(i).sql_name() <<
+                                       setw(widths[1]) << os.str() <<
                                        setw(widths[2]) << cname <<
                                        endl;
                }

Modified: trunk/examples/printdata.cpp
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/examples/printdata.cpp?rev=2020&r1=2019&r2=2020&view=diff
==============================================================================
--- trunk/examples/printdata.cpp (original)
+++ trunk/examples/printdata.cpp Wed Dec 26 23:00:20 2007
@@ -55,7 +55,7 @@
 
 void
 print_stock_row(const mysqlpp::sql_char& item, mysqlpp::sql_bigint num,
-               mysqlpp::sql_double weight, mysqlpp::sql_double price,
+               mysqlpp::sql_double weight, mysqlpp::sql_decimal price,
                const mysqlpp::sql_date& date)
 {
        char buf[100];

Modified: trunk/examples/printdata.h
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/examples/printdata.h?rev=2020&r1=2019&r2=2020&view=diff
==============================================================================
--- trunk/examples/printdata.h (original)
+++ trunk/examples/printdata.h Wed Dec 26 23:00:20 2007
@@ -34,7 +34,7 @@
 void print_stock_row(const mysqlpp::Row& r);
 void print_stock_row(const mysqlpp::sql_char& item,
                mysqlpp::sql_bigint num, mysqlpp::sql_double weight,
-               mysqlpp::sql_double price, const mysqlpp::sql_date& date);
+               mysqlpp::sql_decimal price, const mysqlpp::sql_date& date);
 void print_stock_rows(mysqlpp::StoreQueryResult& res);
 void print_stock_table(mysqlpp::Query& query);
 

Modified: trunk/examples/resetdb.cpp
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/examples/resetdb.cpp?rev=2020&r1=2019&r2=2020&view=diff
==============================================================================
--- trunk/examples/resetdb.cpp (original)
+++ trunk/examples/resetdb.cpp Wed Dec 26 23:00:20 2007
@@ -125,7 +125,7 @@
                                "  item CHAR(30) NOT NULL, " <<
                                "  num BIGINT NOT NULL, " <<
                                "  weight DOUBLE NOT NULL, " <<
-                               "  price DOUBLE NOT NULL, " <<
+                               "  price DECIMAL(6,2) NOT NULL, " <<
                                "  sdate DATE NOT NULL, " <<
                                "  description MEDIUMTEXT NULL) " <<
                                "ENGINE = InnoDB " <<


_______________________________________________
Mysqlpp-commits mailing list
[email protected]
https://mail.gna.org/listinfo/mysqlpp-commits

Reply via email to