Loading storage/public/mozIStorageStatement.idl +4 −5 Original line number Diff line number Diff line Loading @@ -41,10 +41,11 @@ #include "mozIStorageValueArray.idl" interface mozIStorageConnection; interface nsISimpleEnumerator; interface mozIStorageStatementCallback; interface mozIStoragePendingStatement; [scriptable, uuid(52d740cd-1c25-471f-a848-98d1a00a2963)] [scriptable, uuid(471e161a-af46-4eb3-adf6-f6b0c41fe81c)] interface mozIStorageStatement : mozIStorageValueArray { /** * Finalizes a statement so you can successfully close a database connection. Loading Loading @@ -75,10 +76,8 @@ interface mozIStorageStatement : mozIStorageValueArray { /** * Returns the index of the named parameter. * * @param aName * The name of the parameter you want the index for. This does not * include the leading ':'. * @returns the index of the named parameter. * @param aName The name of the parameter you want the index for. * @return The index of the named parameter. */ unsigned long getParameterIndex(in AUTF8String aName); Loading storage/src/mozStorageStatement.cpp +1 −5 Original line number Diff line number Diff line Loading @@ -345,12 +345,8 @@ Statement::GetParameterIndex(const nsACString &aName, if (!mDBStatement) return NS_ERROR_NOT_INITIALIZED; // We do not accept any forms of names other than ":name", but we need to add // the colon for SQLite. nsCAutoString name(":"); name.Append(aName); int ind = ::sqlite3_bind_parameter_index(mDBStatement, PromiseFlatCString(name).get()); PromiseFlatCString(aName).get()); if (ind == 0) // Named parameter not found. return NS_ERROR_INVALID_ARG; Loading storage/src/mozStorageStatementParams.cpp +6 −3 Original line number Diff line number Diff line Loading @@ -91,8 +91,9 @@ StatementParams::SetProperty(nsIXPConnectWrappedNative *aWrapper, } else if (JSVAL_IS_STRING(aId)) { JSString *str = JSVAL_TO_STRING(aId); NS_ConvertUTF16toUTF8 name(::JS_GetStringChars(str), ::JS_GetStringLength(str)); nsCAutoString name(":"); name.Append(NS_ConvertUTF16toUTF8(::JS_GetStringChars(str), ::JS_GetStringLength(str))); // check to see if there's a parameter with this name PRUint32 index; Loading Loading @@ -205,9 +206,11 @@ StatementParams::NewResolve(nsIXPConnectWrappedNative *aWrapper, jschar *nameChars = ::JS_GetStringChars(str); size_t nameLength = ::JS_GetStringLength(str); nsCAutoString name(":"); name.Append(NS_ConvertUTF16toUTF8(nameChars, nameLength)); // Check to see if there's a parameter with this name, and if not, let // the rest of the prototype chain be checked. NS_ConvertUTF16toUTF8 name(nameChars, nameLength); nsresult rv = mStatement->GetParameterIndex(name, &idx); if (NS_FAILED(rv)) return NS_OK; Loading storage/test/unit/test_storage_statement.js +4 −4 Original line number Diff line number Diff line Loading @@ -69,16 +69,16 @@ function test_getParameterName() function test_getParameterIndex_different() { var stmt = createStatement("SELECT * FROM test WHERE id = :id OR name = :name"); do_check_eq(0, stmt.getParameterIndex("id")); do_check_eq(1, stmt.getParameterIndex("name")); do_check_eq(0, stmt.getParameterIndex(":id")); do_check_eq(1, stmt.getParameterIndex(":name")); stmt.reset(); stmt.finalize(); } function test_getParameterIndex_same() { var stmt = createStatement("SELECT * FROM test WHERE id = :test OR name = :test"); do_check_eq(0, stmt.getParameterIndex("test")); var stmt = createStatement("SELECT * FROM test WHERE id = @test OR name = @test"); do_check_eq(0, stmt.getParameterIndex("@test")); stmt.reset(); stmt.finalize(); } Loading Loading
storage/public/mozIStorageStatement.idl +4 −5 Original line number Diff line number Diff line Loading @@ -41,10 +41,11 @@ #include "mozIStorageValueArray.idl" interface mozIStorageConnection; interface nsISimpleEnumerator; interface mozIStorageStatementCallback; interface mozIStoragePendingStatement; [scriptable, uuid(52d740cd-1c25-471f-a848-98d1a00a2963)] [scriptable, uuid(471e161a-af46-4eb3-adf6-f6b0c41fe81c)] interface mozIStorageStatement : mozIStorageValueArray { /** * Finalizes a statement so you can successfully close a database connection. Loading Loading @@ -75,10 +76,8 @@ interface mozIStorageStatement : mozIStorageValueArray { /** * Returns the index of the named parameter. * * @param aName * The name of the parameter you want the index for. This does not * include the leading ':'. * @returns the index of the named parameter. * @param aName The name of the parameter you want the index for. * @return The index of the named parameter. */ unsigned long getParameterIndex(in AUTF8String aName); Loading
storage/src/mozStorageStatement.cpp +1 −5 Original line number Diff line number Diff line Loading @@ -345,12 +345,8 @@ Statement::GetParameterIndex(const nsACString &aName, if (!mDBStatement) return NS_ERROR_NOT_INITIALIZED; // We do not accept any forms of names other than ":name", but we need to add // the colon for SQLite. nsCAutoString name(":"); name.Append(aName); int ind = ::sqlite3_bind_parameter_index(mDBStatement, PromiseFlatCString(name).get()); PromiseFlatCString(aName).get()); if (ind == 0) // Named parameter not found. return NS_ERROR_INVALID_ARG; Loading
storage/src/mozStorageStatementParams.cpp +6 −3 Original line number Diff line number Diff line Loading @@ -91,8 +91,9 @@ StatementParams::SetProperty(nsIXPConnectWrappedNative *aWrapper, } else if (JSVAL_IS_STRING(aId)) { JSString *str = JSVAL_TO_STRING(aId); NS_ConvertUTF16toUTF8 name(::JS_GetStringChars(str), ::JS_GetStringLength(str)); nsCAutoString name(":"); name.Append(NS_ConvertUTF16toUTF8(::JS_GetStringChars(str), ::JS_GetStringLength(str))); // check to see if there's a parameter with this name PRUint32 index; Loading Loading @@ -205,9 +206,11 @@ StatementParams::NewResolve(nsIXPConnectWrappedNative *aWrapper, jschar *nameChars = ::JS_GetStringChars(str); size_t nameLength = ::JS_GetStringLength(str); nsCAutoString name(":"); name.Append(NS_ConvertUTF16toUTF8(nameChars, nameLength)); // Check to see if there's a parameter with this name, and if not, let // the rest of the prototype chain be checked. NS_ConvertUTF16toUTF8 name(nameChars, nameLength); nsresult rv = mStatement->GetParameterIndex(name, &idx); if (NS_FAILED(rv)) return NS_OK; Loading
storage/test/unit/test_storage_statement.js +4 −4 Original line number Diff line number Diff line Loading @@ -69,16 +69,16 @@ function test_getParameterName() function test_getParameterIndex_different() { var stmt = createStatement("SELECT * FROM test WHERE id = :id OR name = :name"); do_check_eq(0, stmt.getParameterIndex("id")); do_check_eq(1, stmt.getParameterIndex("name")); do_check_eq(0, stmt.getParameterIndex(":id")); do_check_eq(1, stmt.getParameterIndex(":name")); stmt.reset(); stmt.finalize(); } function test_getParameterIndex_same() { var stmt = createStatement("SELECT * FROM test WHERE id = :test OR name = :test"); do_check_eq(0, stmt.getParameterIndex("test")); var stmt = createStatement("SELECT * FROM test WHERE id = @test OR name = @test"); do_check_eq(0, stmt.getParameterIndex("@test")); stmt.reset(); stmt.finalize(); } Loading