Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8797739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:54:56+00:00 2026-06-13T23:54:56+00:00

I have a table in OpenERP/PostgreSQL with the following columns: name and description .

  • 0

I have a table in OpenERP/PostgreSQL with the following columns: name and description.

I added the following validation for unique name:

_sql_constraints = [('unique_name', 'unique(name)', 'A record with the same name already exists.')]

It works fine but it is case sensitive. Currently, it accepts values such as “Mickey”, “MICKEY” and “mickey”:

Wrong Way:
--------------------------
| name   | description   |
--------------------------
| mickey | not a mouse   |
--------------------------
| MICKEY | not a mouse   |
--------------------------
| Mickey | not a mouse   |
--------------------------

Is there a way to revise the validation code so that it will not allow users to add several values such as “Mickey”, “MICKEY” and “mickey”? How can I make the unique key validation case insensitive?

Right Way:
--------------------------------
| name         | description   |
--------------------------------
| mickey       | not a mouse   |
--------------------------------
| mickey mouse | is a mouse    |
--------------------------------
| donald       | is a duck     |
--------------------------------
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:54:58+00:00Added an answer on June 13, 2026 at 11:54 pm

    For case insensitive constraints check out HERE
    else you can always use Openerp Constraints instead of SQL .

    for openerp Constraints

    check the example

    def _check_unique_insesitive(self, cr, uid, ids, context=None):
        sr_ids = self.search(cr, 1 ,[], context=context)
        lst = [
                x.FIELD.lower() for x in self.browse(cr, uid, sr_ids, context=context)
                if x.FIELD and x.id not in ids
              ]
        for self_obj in self.browse(cr, uid, ids, context=context):
            if self_obj.FILD and self_obj.FILD.lower() in  lst:
                return False
        return True
    
    _constraints = [(_check_unique_insesitive, 'Error: UNIQUE MSG', ['FIELD'])]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table with following details Table name EMPLOYEE and columns EMPID (PK smallint
I have table Players with columns: ID Name Points What is most efficient way
I have table with 5 columns ------------------------------------------------------ |_id(mongo default)| link | name| street|zip |
I have table with 300 000 records (MyISAM). I get record from this table
I have table with two columns (varchar from, varchar to). This table represents connections
I have table in my database which has fields of ID,NAME,CONTEXT. I am showing
I have table the following data structure in SQL Server: ID Date Allocation 1,
I have table Cars Id nvarchar(25) PK Name nvarchar(max) And there is some records.
I have table named 'Dictionary' with columns as follow: ID bigint TYPE varchar (200)
I have table (call it my_table ) that can be simplified like this: NAME,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.