'Test query construction for non-text fields with text operator'

@unittest.skipIf((not current.deployment_settings.has_module('org')), 'org    module    disabled')
def testTextOperatorWithNonTextField(self):

    s3db = current.s3db
    assertEqual = self.assertEqual
    assertTrue = self.assertTrue
    q = FS('id').lower().like('%123%')
    resource = s3db.resource('org_organisation', filter=q)
    query = resource.rfilter.get_query()
    org_organisation = resource.table
    expected = (((org_organisation.deleted != True) & (org_organisation.id > 0)) & org_organisation.id.like('%123%'))
    assertEqual(str(query), str(expected))
    q = FS('id').lower().like('%12%3%')
    resource = s3db.resource('org_organisation', filter=q)
    query = resource.rfilter.get_query()
    org_organisation = resource.table
    expected = (((org_organisation.deleted != True) & (org_organisation.id > 0)) & org_organisation.id.like('%12%3%'))
    assertEqual(str(query), str(expected))
    q = FS('id').lower().like('%abc%')
    resource = s3db.resource('org_organisation', filter=q)
    query = resource.rfilter.get_query()
    org_organisation = resource.table
    expected = (((org_organisation.deleted != True) & (org_organisation.id > 0)) & org_organisation.id.like('%abc%'))
    assertEqual(str(query), str(expected))
