Skip to content

Commit

Permalink
Hello 0.3.5 version! for sacrud/pyramid_sacrud#107
Browse files Browse the repository at this point in the history
  • Loading branch information
uralbash committed Dec 2, 2015
1 parent a474e78 commit 77da596
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
@@ -1,3 +1,8 @@
0.3.4 (2015-12-02)
------------------

- fix create/update with sqlalchemy.sql.null value

0.3.4 (2015-11-30)
------------------

Expand Down
4 changes: 3 additions & 1 deletion sacrud/preprocessing.py
Expand Up @@ -16,6 +16,8 @@

import six

import sqlalchemy

from .common import get_columns


Expand Down Expand Up @@ -154,7 +156,7 @@ def check_type(self, table, key):
column_type not in ['JSON', 'JSONB', 'HSTORE']:
value = value[0]

if not value\
if not isinstance(value, sqlalchemy.sql.elements.Null) and not value\
and not hasattr(value, 'filename')\
and not column_type == 'Boolean':
if self.column.default or self.column.primary_key:
Expand Down
2 changes: 2 additions & 0 deletions sacrud/tests/__init__.py
Expand Up @@ -136,6 +136,7 @@ class User(Base):
name = Column(String, default='')
fullname = Column(String)
password = Column(String, info={'verbose_name': 'user password'})
age = Column(Integer)
sex = Column(Enum('male',
'female',
'alien',
Expand All @@ -158,6 +159,7 @@ def foo(self):

def __init__(self, name, fullname, password, sex='unknown', groups=[]):
self.name = name
self.age = 0
self.fullname = fullname
self.password = password
self.sex = sex
Expand Down
11 changes: 11 additions & 0 deletions sacrud/tests/test_action.py
Expand Up @@ -7,6 +7,7 @@
# Distributed under terms of the MIT license.
import json

import sqlalchemy
import transaction
from sacrud.action import CRUD
from sacrud.tests import (
Expand Down Expand Up @@ -284,6 +285,16 @@ def test_update_by_int_id(self):
db_user = self.session.query(User).get(user.id)
self.assertEqual(db_user.name, 'Petya')

def test_update_from_0_to_null(self):
user = self._add_item(User, 'Vasya', 'Pupkin', '123')
user = self.session.query(User).get(user.id)
self.assertEqual(user.age, 0)

CRUD(self.session, User).update(user.id,
data={'age': sqlalchemy.sql.null()})
db_user = self.session.query(User).get(user.id)
self.assertEqual(db_user.age, None)

def test_update_json_by_int_id(self):
user = self._add_item(User, 'Vasya', 'Pupkin', "123")
user = self.session.query(User).get(user.id)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -11,7 +11,7 @@ def read(name):

setup(
name='sacrud',
version='0.3.4',
version='0.3.5',
url='http://github.com/ITCase/sacrud/',
author='Svintsov Dmitry',
author_email='root@uralbash.ru',
Expand Down
10 changes: 0 additions & 10 deletions tox.ini

This file was deleted.

0 comments on commit 77da596

Please sign in to comment.