Commit 831a3e73 authored by Shawn Wilsher's avatar Shawn Wilsher
Browse files

Backed out changeset b6f09258a505 (bug 490833).

parent 7c59976c
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -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.
@@ -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);

+1 −5
Original line number Diff line number Diff line
@@ -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;

+6 −3
Original line number Diff line number Diff line
@@ -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;
@@ -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;
+4 −4
Original line number Diff line number Diff line
@@ -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();
}