Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #1213 (closed defect: duplicate)

Opened 4 years ago

Last modified 3 years ago

[XPATCH] Postgresql with null in conditions

Reported by: Rodrigo K Assigned to: David
Priority: normal Milestone: 1.0
Component: ActiveRecord Version: 0.12.1
Severity: normal Keywords:
Cc: michael@koziarski.com

Description

ActiveRecord do "SELEC * FROM table WHERE column = NULL" instead of "SELEC * FROM table WHERE column IS NULL", and the same for "!= NULL" and "IS NOT NULL". It correts the postgresql addapter by adding a new method convert_sql_with_null.

Attachments

postgresql_with_null_condition.patch (0.8 kB) - added by Rodrigo K on 04/28/05 08:52:33.

Change History

04/28/05 08:52:33 changed by Rodrigo K

  • attachment postgresql_with_null_condition.patch added.

04/30/05 14:48:18 changed by david

  • summary changed from [PATCH] Postgresql with null in conditions to [XPATCH] Postgresql with null in conditions.

This would apply pretty inconsistently as conditions used on updates wouldn't be part of it. That needs to be remedied. Also, are there any reason this wouldn't apply to other databases?

05/01/05 20:13:39 changed by nzkoz

  • cc set to michael@koziarski.com.
  • milestone set to 1.0.

I can't speak for MSSQL (though I've used ASE from whence it came) but is null and is not null are supported by the rest of the adapters.

This should probably be included before 1.0, if noone else steps up I'll finish the patch.

06/01/05 11:36:49 changed by wishdev@gmail.com

I think this is a really bad patch. What if you had a string that you were trying to match something like

SELECT * FROM tbl WHERE col = "= NULL"

As stupid as this example looks, this patch would blow that up wihout much ability to even work around this patch.

I've got all the places in the code identified that use = NULL (for the Firebird adapter I'm building)..... at least any area that uses = NULL within a unittest. If you would prefer a patch that modified those areas to use IS NULL then I would be more then happy to submit such a patch which would, in my opinion, be a much cleaner patch to this issue.

06/01/05 14:22:10 changed by nzkoz

Wishdev, Your points are valid, that's why it's in the needy patches queue. However fixing rails to use 'is null' is probably a reasonable goal.

06/12/05 05:59:36 changed by bitsweat

  • status changed from new to closed.
  • resolution set to duplicate.

See Ticket #1391.