Changeset 59
- Timestamp:
- 03/04/07 00:04:22 (2 years ago)
- Files:
-
- trunk/buildme.d (modified) (7 diffs)
- trunk/dbi/DBIException.d (modified) (5 diffs)
- trunk/dbi/Database.d (modified) (7 diffs)
- trunk/dbi/ErrorCode.d (modified) (1 diff)
- trunk/dbi/Result.d (modified) (1 diff)
- trunk/dbi/Row.d (modified) (6 diffs)
- trunk/dbi/Statement.d (modified) (11 diffs)
- trunk/dbi/all.d (modified) (1 diff)
- trunk/dbi/ib/IbDatabase.d (modified) (3 diffs)
- trunk/dbi/ib/IbResult.d (modified) (3 diffs)
- trunk/dbi/ib/all.d (modified) (1 diff)
- trunk/dbi/ib/imp.d (modified) (4 diffs)
- trunk/dbi/msql/MsqlDatabase.d (modified) (3 diffs)
- trunk/dbi/msql/MsqlResult.d (modified) (3 diffs)
- trunk/dbi/msql/all.d (modified) (1 diff)
- trunk/dbi/msql/imp.d (modified) (2 diffs)
- trunk/dbi/mssql/MssqlDatabase.d (modified) (3 diffs)
- trunk/dbi/mssql/MssqlDate.d (modified) (2 diffs)
- trunk/dbi/mssql/MssqlResult.d (modified) (3 diffs)
- trunk/dbi/mssql/all.d (modified) (1 diff)
- trunk/dbi/mssql/imp.d (modified) (5 diffs)
- trunk/dbi/mysql/MysqlDatabase.d (modified) (9 diffs)
- trunk/dbi/mysql/MysqlError.d (modified) (1 diff)
- trunk/dbi/mysql/MysqlResult.d (modified) (2 diffs)
- trunk/dbi/mysql/all.d (modified) (1 diff)
- trunk/dbi/mysql/imp.d (modified) (2 diffs)
- trunk/dbi/odbc/OdbcDatabase.d (modified) (17 diffs)
- trunk/dbi/odbc/OdbcResult.d (modified) (8 diffs)
- trunk/dbi/odbc/all.d (modified) (1 diff)
- trunk/dbi/oracle/OracleDatabase.d (modified) (2 diffs)
- trunk/dbi/oracle/OracleResult.d (modified) (3 diffs)
- trunk/dbi/oracle/all.d (modified) (1 diff)
- trunk/dbi/oracle/imp/nzerror.d (modified) (4 diffs)
- trunk/dbi/oracle/imp/nzt.d (modified) (33 diffs)
- trunk/dbi/oracle/imp/oci.d (modified) (10 diffs)
- trunk/dbi/oracle/imp/oci1.d (modified) (3 diffs)
- trunk/dbi/oracle/imp/oci8dp.d (modified) (4 diffs)
- trunk/dbi/oracle/imp/ociap.d (modified) (316 diffs)
- trunk/dbi/oracle/imp/ociapr.d (modified) (31 diffs)
- trunk/dbi/oracle/imp/ocidef.d (modified) (25 diffs)
- trunk/dbi/oracle/imp/ocidem.d (modified) (3 diffs)
- trunk/dbi/oracle/imp/ocidfn.d (modified) (2 diffs)
- trunk/dbi/oracle/imp/ociextp.d (modified) (7 diffs)
- trunk/dbi/oracle/imp/ocikpr.d (modified) (2 diffs)
- trunk/dbi/oracle/imp/ocixmldb.d (modified) (4 diffs)
- trunk/dbi/oracle/imp/odci.d (modified) (2 diffs)
- trunk/dbi/oracle/imp/oratypes.d (modified) (2 diffs)
- trunk/dbi/oracle/imp/ori.d (modified) (62 diffs)
- trunk/dbi/oracle/imp/orid.d (modified) (3 diffs)
- trunk/dbi/oracle/imp/orl.d (modified) (23 diffs)
- trunk/dbi/oracle/imp/oro.d (modified) (6 diffs)
- trunk/dbi/oracle/imp/ort.d (modified) (101 diffs)
- trunk/dbi/oracle/imp/xa.d (modified) (2 diffs)
- trunk/dbi/pg/PgDatabase.d (modified) (11 diffs)
- trunk/dbi/pg/PgError.d (modified) (1 diff)
- trunk/dbi/pg/PgResult.d (modified) (5 diffs)
- trunk/dbi/pg/all.d (modified) (2 diffs)
- trunk/dbi/pg/imp.d (modified) (10 diffs)
- trunk/dbi/sqlite/SqliteDatabase.d (modified) (11 diffs)
- trunk/dbi/sqlite/SqliteError.d (modified) (1 diff)
- trunk/dbi/sqlite/SqliteResult.d (modified) (2 diffs)
- trunk/dbi/sqlite/all.d (modified) (1 diff)
- trunk/dbi/sqlite/imp.d (modified) (6 diffs)
- trunk/docs/buildme.html (modified) (2 diffs)
- trunk/docs/dbi/DBIException.html (modified) (1 diff)
- trunk/docs/dbi/Database.html (modified) (2 diffs)
- trunk/docs/dbi/ErrorCode.html (modified) (1 diff)
- trunk/docs/dbi/Result.html (modified) (1 diff)
- trunk/docs/dbi/Row.html (modified) (1 diff)
- trunk/docs/dbi/Statement.html (modified) (1 diff)
- trunk/docs/dbi/ib/IbDatabase.html (modified) (1 diff)
- trunk/docs/dbi/ib/IbResult.html (modified) (1 diff)
- trunk/docs/dbi/ib/imp.html (modified) (1 diff)
- trunk/docs/dbi/msql/MsqlDatabase.html (modified) (1 diff)
- trunk/docs/dbi/msql/MsqlResult.html (modified) (1 diff)
- trunk/docs/dbi/msql/imp.html (modified) (1 diff)
- trunk/docs/dbi/mssql (copied) (copied from branches/0.2-stable/docs/dbi/mssql)
- trunk/docs/dbi/mssql/MssqlDatabase.html (copied) (copied from branches/0.2-stable/docs/dbi/mssql/MssqlDatabase.html)
- trunk/docs/dbi/mssql/MssqlDate.html (copied) (copied from branches/0.2-stable/docs/dbi/mssql/MssqlDate.html)
- trunk/docs/dbi/mssql/MssqlResult.html (copied) (copied from branches/0.2-stable/docs/dbi/mssql/MssqlResult.html)
- trunk/docs/dbi/mssql/imp.html (copied) (copied from branches/0.2-stable/docs/dbi/mssql/imp.html)
- trunk/docs/dbi/mysql/MysqlDatabase.html (modified) (1 diff)
- trunk/docs/dbi/mysql/MysqlError.html (modified) (1 diff)
- trunk/docs/dbi/mysql/MysqlResult.html (modified) (1 diff)
- trunk/docs/dbi/odbc/OdbcDatabase.html (modified) (4 diffs)
- trunk/docs/dbi/odbc/OdbcResult.html (modified) (1 diff)
- trunk/docs/dbi/oracle/OracleDatabase.html (modified) (1 diff)
- trunk/docs/dbi/oracle/OracleResult.html (modified) (1 diff)
- trunk/docs/dbi/oracle/imp/oci.html (modified) (4 diffs)
- trunk/docs/dbi/pg/PgDatabase.html (modified) (3 diffs)
- trunk/docs/dbi/pg/PgError.html (modified) (1 diff)
- trunk/docs/dbi/pg/PgResult.html (modified) (1 diff)
- trunk/docs/dbi/pg/imp.html (modified) (7 diffs)
- trunk/docs/dbi/sqlite/SqliteDatabase.html (modified) (1 diff)
- trunk/docs/dbi/sqlite/SqliteError.html (modified) (1 diff)
- trunk/docs/dbi/sqlite/SqliteResult.html (modified) (1 diff)
- trunk/docs/dbi/sqlite/imp.html (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/buildme.d
r41 r59 29 29 * Authors: The D DBI project 30 30 * 31 * Version: 0.2.4 32 * 33 * Modified: 34 * 2006-10-16 Changed build to bud. 35 * 2006-10-20 Fixed linux sleep issues. 36 * 2006-11-01 Non-Windows library names will now be in the proper style. 37 * 2003-11-09 Fixed a "no effect in expression" warning. 31 * Version: 0.2.5 38 32 * 39 33 * Copyright: BSD license … … 41 35 module buildme; 42 36 43 version (Ares) { 44 private import std.io.FileConst : FileConst; 45 private import std.io.FilePath : FilePath; 46 private import std.c.stdlib : system; 47 48 alias FileConst.PathSeparatorString sep; 49 } else { 37 version (Phobos) { 50 38 private import std.file : chdir, getcwd, isdir, listdir; 51 39 private import std.path : pardir, sep; 52 40 private import std.process : system; 41 } else { 42 private import tango.io.FileConst; 43 private import tango.io.FileProxy : FileProxy; 44 private import tango.stdc.stdlib : system; 45 46 alias FileConst.PathSeparatorString sep; 53 47 } 54 48 … … 79 73 switchesCompiler["-odlibddbi.a"] = true; 80 74 } 81 version ( Ares) {82 switchesCompiler["-version= Ares"] = true;75 version (Phobos) { 76 switchesCompiler["-version=Phobos"] = true; 83 77 } 84 78 } else version (GNU) { … … 97 91 switchesCompiler["-o libddbi.a"] = true; 98 92 } 99 version ( Ares) {100 switchesCompiler["-fversion= Ares"] = true;93 version (Phobos) { 94 switchesCompiler["-fversion=Phobos"] = true; 101 95 } 102 96 } else { … … 109 103 110 104 // Make the "all" list. 111 version (Ares) { 112 // Ares doesn't seem to have a listdir() equivalent. 113 allList["ib"] = true; 114 allList["msql"] = true; 115 allList["mysql"] = true; 116 allList["odbc"] = true; 117 allList["oracle"] = true; 118 allList["pg"] = true; 119 allList["sqlite"] = true; 120 } else { 105 version (Phobos) { 121 106 chdir("dbi"); 122 107 foreach (char[] dir; listdir(getcwd())) { … … 126 111 } 127 112 chdir(pardir); 113 } else { 114 void addDirs (char[] parent, char[] name, bool isDir) { 115 if (isDir && name != ".svn") { 116 allList[name] = true; 117 } 118 } 119 FileProxy proxy = new FileProxy("dbi"); 120 proxy.toList(&addDirs); 128 121 } 129 122 … … 156 149 } 157 150 buildCommand.length = buildCommand.length - 1; 158 if (system("bud " ~ buildCommand)) { 159 version (Windows) { 160 system("pause"); 161 } else version (linux) { 162 system("sleep 5"); 151 version (Phobos) { 152 if (system("bud " ~ buildCommand)) { 153 version (Windows) { 154 system("pause"); 155 } else version (linux) { 156 system("sleep 5"); 157 } 158 } 159 } else { 160 if (system(("bud " ~ buildCommand).ptr)) { 161 version (Windows) { 162 system("pause"); 163 } else version (linux) { 164 system("sleep 5"); 165 } 163 166 } 164 167 } trunk/dbi/DBIException.d
r45 r59 1 /**1 /** 2 2 * Authors: The D DBI project 3 3 * 4 * Version: 0.2. 44 * Version: 0.2.5 5 5 * 6 6 * Copyright: BSD license … … 8 8 module dbi.DBIException; 9 9 10 version ( Ares) {11 private import std. vararg : va_arg;10 version (Phobos) { 11 private import std.stdarg : va_arg; 12 12 } else { 13 private import std.stdarg : va_arg;13 private import tango.core.Vararg : va_arg; 14 14 } 15 15 private import dbi.ErrorCode; … … 34 34 * Params: 35 35 * msg = The message to report to the users. 36 * 36 * 37 37 * Throws: 38 38 * DBIException on invalid arguments. … … 62 62 dbiCode = va_arg!(ErrorCode)(_argptr); 63 63 } else { 64 throw new DBIException("Invalid argument of type \"" ~ _arguments[i].toString() ~ "\" passed to the DBIException constructor."); 64 version (Phobos) { 65 throw new DBIException("Invalid argument of type \"" ~ _arguments[i].toString() ~ "\" passed to the DBIException constructor."); 66 } else { 67 throw new DBIException("Invalid argument of type \"" ~ _arguments[i].toUtf8() ~ "\" passed to the DBIException constructor."); 68 } 65 69 } 66 70 } … … 96 100 return sql; 97 101 } 98 deprecated alias getSql getSQL; 99 102 100 103 private: 101 104 char[] sql; trunk/dbi/Database.d
r46 r59 1 /**1 /** 2 2 * Authors: The D DBI project 3 3 * 4 * Version: 0.2. 44 * Version: 0.2.5 5 5 * 6 6 * Copyright: BSD license … … 8 8 module dbi.Database; 9 9 10 version ( Ares) {11 private static import std. regexp;12 debug (UnitTest) private import std.io.Console;10 version (Phobos) { 11 private static import std.string; 12 debug (UnitTest) private static import std.stdio; 13 13 } else { 14 private static import std.string;15 debug (UnitTest) private import std.stdio;14 private static import tango.text.Util; 15 debug (UnitTest) private static import tango.io.Stdout; 16 16 } 17 17 private import dbi.DBIException, dbi.Result, dbi.Row, dbi.Statement; … … 70 70 */ 71 71 final Statement prepare (char[] sql) { 72 return new Statement(cast(Database)this, sql); 73 } 74 75 /* Escape a string using the database's native method if possible 76 * 77 * Params: 78 * str = The string to escape 79 * 80 * Returns: 81 * The escaped string. 82 */ 83 84 char[] escape (char[] str) 85 { 86 char[] result; 87 int count = 0; 88 89 // Maximum length needed if every char is to be quoted 90 result.length = str.length * 2; 91 for(int i = 0; i < str.length; i++) 92 { 93 switch(str[i]) 94 { 95 case '"': 96 case '\'': 97 case '\\': 98 result[count++] = '\\'; 99 break; 100 default: 101 break; 102 } 103 result[count++] = str[i]; 104 } 105 106 result.length = count; 107 108 return result; 109 } 72 return new Statement(this, sql); 73 } 74 75 /** 76 * Escape a _string using the database's native method, if possible. 77 * 78 * Params: 79 * string = The _string to escape, 80 * 81 * Returns: 82 * The escaped _string. 83 */ 84 char[] escape (char[] string) 85 { 86 char[] result; 87 size_t count = 0; 88 89 // Maximum length needed if every char is to be quoted 90 result.length = string.length * 2; 91 92 for (size_t i = 0; i < string.length; i++) { 93 switch (string[i]) { 94 case '"': 95 case '\'': 96 case '\\': 97 result[count++] = '\\'; 98 break; 99 default: 100 break; 101 } 102 result[count++] = string[i]; 103 } 104 105 result.length = count; 106 return result; 107 } 110 108 111 109 /** … … 198 196 final protected char[][char[]] getKeywords (char[] string) { 199 197 char[][char[]] keywords; 200 version (Ares) { 201 foreach (char[] group; std.regexp.split(string, ";")) { 202 if (group == "") { 203 continue; 204 } 205 char[][] vals = std.regexp.split(group, "="); 206 keywords[vals[0]] = vals[1]; 207 } 208 } else { 198 version (Phobos) { 209 199 foreach (char[] group; std.string.split(string, ";")) { 210 200 if (group == "") { … … 214 204 keywords[vals[0]] = vals[1]; 215 205 } 206 } else { 207 foreach (char[] group; tango.text.Util.delimit(string, ";")) { 208 if (group == "") { 209 continue; 210 } 211 char[][] vals = tango.text.Util.delimit(group, "="); 212 keywords[vals[0]] = vals[1]; 213 } 214 216 215 } 217 216 return keywords; … … 226 225 deprecated int getErrorCode () {return 0;} 227 226 deprecated char[] getErrorMessage () {return "";} 228 229 227 } 230 228 231 229 unittest { 232 version ( Ares) {230 version (Phobos) { 233 231 void s1 (char[] s) { 234 Cout("" ~ s ~ "\n");232 std.stdio.writefln("%s", s); 235 233 } 236 234 237 235 void s2 (char[] s) { 238 Cout(" ..." ~ s ~ "\n");236 std.stdio.writefln(" ...%s", s); 239 237 } 240 238 } else { 241 239 void s1 (char[] s) { 242 writefln("%s", s);240 tango.io.Stdout.Stdout(s).newline(); 243 241 } 244 242 245 243 void s2 (char[] s) { 246 writefln(" ...%s", s); 247 } 248 } 249 244 tango.io.Stdout.Stdout(" ..." ~ s).newline(); 245 } 246 } 250 247 251 248 s1("dbi.Database:"); … … 254 251 s2("getKeywords"); 255 252 char[][char[]] keywords = db.getKeywords("dbname=hi;host=local;"); 256 assert (keywords["dbname"] == "hi");257 assert (keywords["host"] == "local");258 } 253 assert (keywords["dbname"] == "hi"); 254 assert (keywords["host"] == "local"); 255 } trunk/dbi/ErrorCode.d
r45 r59 2 2 * Authors: The D DBI project 3 3 * 4 * Version: 0.2. 44 * Version: 0.2.5 5 5 * 6 6 * Copyright: BSD license trunk/dbi/Result.d
r45 r59 2 2 * Authors: The D DBI project 3 3 * 4 * Version: 0.2. 44 * Version: 0.2.5 5 5 * 6 6 * Copyright: BSD license trunk/dbi/Row.d
r45 r59 1 1 2 2 /** 3 3 * Authors: The D DBI project 4 4 * 5 * Version: 0.2. 45 * Version: 0.2.5 6 6 * 7 7 * Copyright: BSD license … … 9 9 module dbi.Row; 10 10 11 version ( Ares) {12 debug (UnitTest) private import std.io.Console;11 version (Phobos) { 12 debug (UnitTest) private static import std.stdio; 13 13 } else { 14 debug (UnitTest) private import std.stdio;14 debug (UnitTest) private static import tango.io.Stdout; 15 15 } 16 16 private import dbi.DBIException; … … 62 62 * --- 63 63 * 64 * Returns: 64 * Returns: 65 65 * The field's contents. 66 66 */ … … 156 156 */ 157 157 void addField (char[] name, char[] value, char[] decl, int type) { 158 fieldNames ~= name .dup;158 fieldNames ~= name; 159 159 fieldValues ~= value.dup; 160 160 fieldDecls ~= decl.dup; … … 170 170 171 171 unittest { 172 version ( Ares) {172 version (Phobos) { 173 173 void s1 (char[] s) { 174 Cout("" ~ s ~ "\n");174 std.stdio.writefln("%s", s); 175 175 } 176 176 177 177 void s2 (char[] s) { 178 Cout(" ..." ~ s ~ "\n");178 std.stdio.writefln(" ...%s", s); 179 179 } 180 180 } else { 181 181 void s1 (char[] s) { 182 writefln("%s", s);182 tango.io.Stdout.Stdout(s).newline(); 183 183 } 184 184 185 185 void s2 (char[] s) { 186 writefln(" ...%s", s);186 tango.io.Stdout.Stdout(" ..." ~ s).newline(); 187 187 } 188 188 } … … 190 190 s1("dbi.Row:"); 191 191 Row r1 = new Row(); 192 r1.addField("name", "John Doe", "text", 3);193 r1.addField("age", "23","integer", 1);192 r1.addField("name", "John Doe", "text", 3); 193 r1.addField("age", "23", "integer", 1); 194 194 195 195 s2("get(int)"); 196 assert (r1.get(0) == "John Doe");196 assert (r1.get(0) == "John Doe"); 197 197 198 198 s2("get(char[])"); 199 assert (r1.get("name") == "John Doe");199 assert (r1.get("name") == "John Doe"); 200 200 201 201 s2("[int]"); 202 assert (r1[0] == "John Doe");202 assert (r1[0] == "John Doe"); 203 203 204 204 s2("[char[]]"); 205 assert (r1["age"] == "23");205 assert (r1["age"] == "23"); 206 206 207 207 s2("getFieldIndex"); 208 assert (r1.getFieldIndex("name") == 0);208 assert (r1.getFieldIndex("name") == 0); 209 209 210 210 s2("getFieldType"); 211 assert (r1.getFieldType(0) == 3);212 211 assert (r1.getFieldType(0) == 3); 212 213 213 s2("getFieldDecl"); 214 assert (r1.getFieldDecl(1) == "integer");214 assert (r1.getFieldDecl(1) == "integer"); 215 215 } trunk/dbi/Statement.d
r46 r59 1 /**1 /** 2 2 * Authors: The D DBI project 3 3 * 4 * Version: 0.2. 44 * Version: 0.2.5 5 5 * 6 6 * Copyright: BSD license … … 8 8 module dbi.Statement; 9 9 10 version ( Ares) {11 private static import std. regexp;12 debug (UnitTest) private import std.io.Console;10 version (Phobos) { 11 private static import std.string; 12 debug (UnitTest) private static import std.stdio; 13 13 } else { 14 private static import std.string; 15 debug (UnitTest) private import std.stdio; 14 private static import tango.text.Util; 15 private static import tango.text.Regex; 16 debug (UnitTest) private static import tango.io.Stdout; 16 17 } 17 private import dbi.Database, dbi. Result;18 private import dbi.Database, dbi.DBIException, dbi.Result; 18 19 19 20 /** … … 98 99 * The escaped form of string. 99 100 */ 100 char[] escape (char[] string) 101 { 102 if(database !is null) 103 return database.escape(string); 104 else 105 { 106 char[] result; 107 int count = 0; 108 109 // Maximum length needed if every char is to be quoted 110 result.length = string.length * 2; 111 for(int i = 0; i < string.length; i++) 112 { 113 switch(string[i]) 114 { 115 case '"': 116 case '\'': 117 case '\\': 118 result[count++] = '\\'; 119 break; 120 default: 121 break; 122 } 123 result[count++] = string[i]; 124 } 125 126 result.length = count; 127 return result; 128 } 101 char[] escape (char[] string) { 102 if (database !is null) { 103 return database.escape(string); 104 } else { 105 char[] result; 106 size_t count = 0; 107 108 // Maximum length needed if every char is to be quoted 109 result.length = string.length * 2; 110 111 for (size_t i = 0; i < string.length; i++) { 112 switch (string[i]) { 113 case '"': 114 case '\'': 115 case '\\': 116 result[count++] = '\\'; 117 break; 118 default: 119 break; 120 } 121 result[count++] = string[i]; 122 } 123 124 result.length = count; 125 return result; 126 } 129 127 } 130 128 … … 138 136 * Raise an exception if binds.length != count(sql, "?") 139 137 */ 140 char[] getSqlByQM () 141 { 142 char[] result; 143 int i = 0, j = 0, count = 0; 144 145 // binds.length is for the '', only 1 because we replace the ? too 146 result.length = sql.length + binds.length; 147 for(i = 0; i < binds.length; i++) 148 result.length = result.length + binds[i].length; 149 150 for(i = 0; i < sql.length; i++) 151 { 152 if(sql[i] == '?') 153 { 154 result[j++] = '\''; 155 result[j..j + binds[count].length] = binds[count]; 156 j += binds[count++].length; 157 result[j++] = '\''; 158 } 159 else 160 result[j++] = sql[i]; 161 } 162 163 sql = result; 138 char[] getSqlByQM () { 139 char[] result; 140 size_t i = 0, j = 0, count = 0; 141 142 // binds.length is for the '', only 1 because we replace the ? too 143 result.length = sql.length + binds.length; 144 for (i = 0; i < binds.length; i++) { 145 result.length = result.length + binds[i].length; 146 } 147 148 for (i = 0; i < sql.length; i++) { 149 if (sql[i] == '?') { 150 result[j++] = '\''; 151 result[j .. j + binds[count].length] = binds[count]; 152 j += binds[count++].length; 153 result[j++] = '\''; 154 } 155 else { 156 result[j++] = sql[i]; 157 } 158 } 159 160 sql = result; 164 161 return result; 165 162 } … … 176 173 char[] getSqlByFN () { 177 174 char[] result = sql; 178 ptrdiff_t begIdx = 0, endIdx = 0;179 version (Ares) {180 while ((beg Idx = std.regexp.find(result, ":")) != -1 && (endIdx = std.regexp.find(result[begIdx + 1 .. length], ":")) != -1) {181 result = result[0 .. beg Idx] ~ "'" ~ getBoundValue(result[begIdx + 1.. begIdx + endIdx + 1])~ "'" ~ result[begIdx + endIdx + 2 .. length];175 version (Phobos) { 176 ptrdiff_t beginIndex = 0, endIndex = 0; 177 while ((beginIndex = std.string.find(result, ":")) != -1 && (endIndex = std.string.find(result[beginIndex + 1 .. length], ":")) != -1) { 178 result = result[0 .. beginIndex] ~ "'" ~ getBoundValue(result[beginIndex + 1.. beginIndex + endIndex + 1]) ~ "'" ~ result[beginIndex + endIndex + 2 .. length]; 182 179 } 183 180 } else { 184 while ((begIdx = std.string.find(result, ":")) != -1 && (endIdx = std.string.find(result[begIdx + 1 .. length], ":")) != -1) { 185 result = result[0 .. begIdx] ~ "'" ~ getBoundValue(result[begIdx + 1.. begIdx + endIdx + 1])~ "'" ~ result[begIdx + endIdx + 2 .. length]; 181 uint beginIndex = 0, endIndex = 0; 182 while ((beginIndex = tango.text.Util.locate(result, ':')) != result.length && (endIndex = tango.text.Util.locate(result, ':', beginIndex + 1)) != result.length) { 183 result = result[0 .. beginIndex] ~ "'" ~ getBoundValue(result[beginIndex + 1 .. endIndex]) ~ "'" ~ result[endIndex + 1 .. length]; 186 184 } 187 185 } … … 196 194 */ 197 195 char[] getSql () { 198 version (Ares) { 199 if (std.regexp.find(sql, "\\u003F") != size_t.max) { 200 return getSqlByQM(); 201 } else if (std.regexp.find(sql, ":") != size_t.max) { 202 return getSqlByFN(); 203 } else { 204 return sql; 205 } 206 } else { 196 version (Phobos) { 207 197 if (std.string.find(sql, "?") != -1) { 208 198 return getSqlByQM(); … … 212 202 return sql; 213 203 } 204 } else { 205 if (tango.text.Util.contains(sql, '?')) { 206 return getSqlByQM(); 207 } else if (tango.text.Util.contains(sql, ':')) { 208 return getSqlByFN(); 209 } else { 210 return sql; 211 } 214 212 } 215 213 } … … 223 221 * Returns: 224 222 * The bound value of fn. 223 * 224 * Throws: 225 * DBIException if fn is not bound 225 226 */ 226 227 char[] getBoundValue (char[] fn) { 227 for ( ptrdiff_t idx = 0; idx < bindsFNs.length; idx++) {228 if (bindsFNs[i dx] == fn) {229 return binds[i dx];230 } 231 } 232 return null;228 for (size_t index = 0; index < bindsFNs.length; index++) { 229 if (bindsFNs[index] == fn) { 230 return binds[index]; 231 } 232 } 233 throw new DBIException(fn ~ " is not bound in the Statement."); 233 234 } 234 235 } 235 236 236 237 unittest { 237 version ( Ares) {238 version (Phobos) { 238 239 void s1 (char[] s) { 239 Cout("" ~ s ~ "\n");240 std.stdio.writefln("%s", s); 240 241 } 241 242 242 243 void s2 (char[] s) { 243 Cout(" ..." ~ s ~ "\n");244 std.stdio.writefln(" ...%s", s); 244 245 } 245 246 } else { 246 247 void s1 (char[] s) { 247 writefln("%s", s);248 tango.io.Stdout.Stdout(s).newline(); 248 249 } 249 250 250 251 void s2 (char[] s) { 251 writefln(" ...%s", s);252 tango.io.Stdout.Stdout(" ..." ~ s).newline(); 252 253 } 253 254 } … … 258 259 259 260 s2("escape"); 260 assert (stmt.escape("John Mc'Donald") == "John Mc\\'Donald");261 assert (stmt.escape("John Mc'Donald") == "John Mc\\'Donald"); 261 262 262 263 s2("simple sql"); 263 264 stmt = new Statement(null, "SELECT * FROM people"); 264 assert (stmt.getSql() == "SELECT * FROM people");265 assert (stmt.getSql() == "SELECT * FROM people"); 265 266 266 267 s2("bind by '?'"); … … 268 269 stmt.bind(1, "10"); 269 270 stmt.bind(2, "John Mc'Donald"); 270 271 assert(stmt.getSql() == resultingSql); 271 assert (stmt.getSql() == resultingSql); 272 272 273 273 /+ 274 274 s2("bind by '?' sent to getSql via variable arguments"); 275 275 stmt = new Statement("SELECT * FROM people WHERE id = ? OR name LIKE ?"); 276 assert (stmt.getSql("10", "John Mc'Donald") == resultingSql);276 assert (stmt.getSql("10", "John Mc'Donald") == resultingSql); 277 277 +/ 278 278 … … 281 281 stmt.bind("id", "10"); 282 282 stmt.bind("name", "John Mc'Donald"); 283 assert (stmt.getBoundValue("name") == "John Mc\\'Donald");284 assert (stmt.getSql() == resultingSql);283 assert (stmt.getBoundValue("name") == "John Mc\\'Donald"); 284 assert (stmt.getSql() == resultingSql); 285 285 } trunk/dbi/all.d
r45 r59 2 2 * Authors: The D DBI project 3 3 * 4 * Version: 0.2. 44 * Version: 0.2.5 5 5 * 6 6 * Copyright: BSD license trunk/dbi/ib/IbDatabase.d
r45 r59 1 /**1 /** 2 2 * Authors: The D DBI project 3 3 * 4 * Version: 0.2. 44 * Version: 0.2.5 5 5 * 6 6 * Copyright: BSD license … … 40 40 41 41 /** 42 * 42 * 43 43 */ 44 44 override void connect (char[] params, char[] username = null, char[] password = null) { … … 105 105 106 106 private: 107 107 108 108 } trunk/dbi/ib/IbResult.d
r45 r59 2 2 * Authors: The D DBI project 3 3 * 4 * Version: 0.2. 44 * Version: 0.2.5 5 5 * 6 6 * Copyright: BSD license … … 20 20 public: 21 21 this () { 22 22 23 23 } 24 24 … … 37 37 */ 38 38 override void finish () { 39 39 40 40 } 41 41 trunk/dbi/ib/all.d
r45 r59 2 2 * Authors: The D DBI project
