-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OracleParameterCollection exception in insert_version_and_get_version_id() #58
Comments
Ok seems this was happening because a command was failing and retrying (and the command was already used or something). First failure was:
This is happening because of incorrect null parameter handling in OracleDatabase.create_parameter. It should be: private IParameter<IDbDataParameter> create_parameter(string name, DbType type, object value, int? size)
{
IDbCommand command = server_connection.underlying_type().CreateCommand();
var parameter = command.CreateParameter();
command.Dispose();
parameter.Direction = ParameterDirection.Input;
parameter.ParameterName = name;
parameter.DbType = type;
parameter.Value = value ?? DBNull.Value; // <--- fixed
if (size != null)
{
parameter.Size = size.Value;
}
return new AdoNetParameter(parameter);
} This now works. However I found another bug in some SQL: SELECT id
FROM (SELECT * FROM {0}_{1}
WHERE
NVL(repository_path, '') = NVL(:repository_path, '') -- fixed
ORDER BY entry_date DESC)
WHERE ROWNUM < 2 This happens because NULL == NULL does not evaluate to true in PL/SQL. If you do not have a repository path specified, this WHERE clause would always have evaluated to false and thus never returned any rows. As well I found another bug in insert_version_and_get_version_id: return Convert.ToInt64((decimal)run_sql_scalar(get_version_id_script(), ConnectionType.Default, select_parameters)); The (decimal) cast is not required here. In fact it actually causes errors - in my case the unneccessary cast was causing a NullReferenceException (because there were no rows in the Version table, run_sql_scalar returned null which cannot be casted to a value type). I'm at work at the moment but will try to get a pull request to address these issues when I get home. |
…ing passed instead of DbNull.Value (issue chucknorris#58)
…l values - Convert.ToInt64 will handle that already. (issue chucknorris#58)
…ing passed instead of DbNull.Value (issue chucknorris#58)
…l values - Convert.ToInt64 will handle that already. (issue chucknorris#58)
This completed. Thanks. |
Happening in version 0.8.5.0.
The text was updated successfully, but these errors were encountered: