{"action":"closed","issue":{"url":"https://api.github.com/repos/psycopg/psycopg2/issues/295","labels_url":"https://api.github.com/repos/psycopg/psycopg2/issues/295/labels{/name}","comments_url":"https://api.github.com/repos/psycopg/psycopg2/issues/295/comments","events_url":"https://api.github.com/repos/psycopg/psycopg2/issues/295/events","html_url":"https://github.com/psycopg/psycopg2/issues/295","id":60149775,"number":295,"title":"Default value doesn't work","user":{"login":"AnderUstarroz","id":8544110,"avatar_url":"https://avatars.githubusercontent.com/u/8544110?v=3","gravatar_id":"","url":"https://api.github.com/users/AnderUstarroz","html_url":"https://github.com/AnderUstarroz","followers_url":"https://api.github.com/users/AnderUstarroz/followers","following_url":"https://api.github.com/users/AnderUstarroz/following{/other_user}","gists_url":"https://api.github.com/users/AnderUstarroz/gists{/gist_id}","starred_url":"https://api.github.com/users/AnderUstarroz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AnderUstarroz/subscriptions","organizations_url":"https://api.github.com/users/AnderUstarroz/orgs","repos_url":"https://api.github.com/users/AnderUstarroz/repos","events_url":"https://api.github.com/users/AnderUstarroz/events{/privacy}","received_events_url":"https://api.github.com/users/AnderUstarroz/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-06T19:50:59Z","updated_at":"2015-03-06T20:07:51Z","closed_at":"2015-03-06T20:07:51Z","body":"I've found an unexpected behavior when executing a Insert. Actually I'm not really sure if the issue is in SQLAlchemy, psycopg2 or aiopg. I'm using the following versions:\r\n\r\n - **SQLAlchemy** (0.9.8)\r\n - **PostgreSQL** (9.3.5)\r\n - **psycopg2** (2.5.4)\r\n - **aiopg** (0.5.1)\r\n\r\nThis is the table definition for the example:\r\n\r\n    import asyncio\r\n    from aiopg.sa import create_engine\r\n    from sqlalchemy import (\r\n      MetaData,\r\n      Column,\r\n      Integer,\r\n      Table,\r\n      String,\r\n    )\r\n    metadata = MetaData()\r\n\r\n    users = Table('users', metadata,\r\n      Column('id_user', Integer, primary_key=True, nullable=False),\r\n      Column('name', String(20), unique=True),\r\n      Column('age', Integer, nullable=False, default=0),\r\n    )\r\n\r\nNow if I try to execute a simple insert to the table just populating the ***id_user*** and ***name***, the column ***age*** should be auto-generated with the default value **0** right? Lets see...\r\n\r\n    @asyncio.coroutine\r\n    def go():\r\n\t  engine = yield from create_engine('postgresql://USER@localhost/DB')\r\n\t  data = {'id_user':1, 'name':'Jimmy' }\r\n\t  stmt = users.insert(values=data, inline=False)\r\n\t  with (yield from engine) as conn:\r\n\t    result = yield from conn.execute(stmt)\r\n\r\n\r\n    loop = asyncio.get_event_loop()\r\n    loop.run_until_complete(go())\r\nThis is the resulting statement with the corresponding error:\r\n\r\n    INSERT INTO users (id_user, name, age) VALUES (1, 'Jimmy', null);\r\n    \r\n    psycopg2.IntegrityError: null value in column \"age\" violates not-null constraint\r\n\r\nI didn't provide the **age** column, so where is that **age = null** value coming from? I was expecting something like this:\r\n\r\n    INSERT INTO users (id_user, name) VALUES (1, 'Jimmy');\r\n\r\nOr if the ***default*** flag actually works should be:\r\n\r\n    INSERT INTO users (id_user, name, Age) VALUES (1, 'Jimmy', 0);\r\n\r\nCould you put some light on this?"}}