Select against MySQL seems to ignore "!= None" parameter

Issue #227 resolved
Former user created an issue

Here's the mysql to create my table. Create it the database "cc" for my test code.

CREATE TABLE `simple` (
  `id` int(11) NOT NULL auto_increment,
  `license_uri` text NOT NULL,
  `search_engine` varchar(255) NOT NULL default  '',
  `count` bigint(20) NOT NULL default '0',
  `timestamp` datetime default NULL,
  `country` varchar(255) default NULL,
  `language` varchar(255) default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1

Here's an INSERT for testing:

INSERT INTO simple (license_uri) VALUES ('http://www.nevermind.com/');

Here's a SELECT to show it got inserted:

SELECT timestamp, count, license_uri FROM simple WHERE license_uri = 'http://www.nevermind.com/';

You'll see timestamp is NULL. Okay, now let's use sqlsoup to select from the table.

Demo code:

# Set up data
from sqlalchemy.ext.sqlsoup import SqlSoup
from sqlalchemy import *
db = SqlSoup('mysql://root:@localhost/cc')
everything = db.simple.select(and_(db.simple.timestamp != None, db.simple.c.license_uri == 'http://www.nevermind.com/'))
for thing in everything:
    if thing.timestamp == None:
        print "BUG!"

This prints "BUG!". It should not; no rows where timestamp == None should ever be returned.

Comments (2)

  1. Former user Account Deleted

    Er, the sample code doesn't work. You can close this until I figure out working minimal sample code. Sorry. . . .

  2. Mike Bayer repo owner

    reopen this when u figure it out. might want to determine if the issue is with SqlSoup or with straight SQL too.

  3. Log in to comment