new version
This commit is contained in:
parent
7a69baf491
commit
f2e62606c7
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,6 +3,7 @@
|
|||||||
*.egg
|
*.egg
|
||||||
dist/*
|
dist/*
|
||||||
.tox/*
|
.tox/*
|
||||||
|
.vscode/*
|
||||||
build/*
|
build/*
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.watchr
|
.watchr
|
||||||
|
|||||||
@ -384,7 +384,7 @@ class Table(object):
|
|||||||
return True
|
return True
|
||||||
for column in columns:
|
for column in columns:
|
||||||
if not self.has_column(column):
|
if not self.has_column(column):
|
||||||
raise DatasetException("Column does not exist: %s" % column)
|
return False
|
||||||
indexes = self.db.inspect.get_indexes(self.name, schema=self.db.schema)
|
indexes = self.db.inspect.get_indexes(self.name, schema=self.db.schema)
|
||||||
for index in indexes:
|
for index in indexes:
|
||||||
if columns == set(index.get('column_names', [])):
|
if columns == set(index.get('column_names', [])):
|
||||||
@ -405,6 +405,10 @@ class Table(object):
|
|||||||
if not self.exists:
|
if not self.exists:
|
||||||
raise DatasetException("Table has not been created yet.")
|
raise DatasetException("Table has not been created yet.")
|
||||||
|
|
||||||
|
for column in columns:
|
||||||
|
if not self.has_column(column):
|
||||||
|
return
|
||||||
|
|
||||||
if not self.has_index(columns):
|
if not self.has_index(columns):
|
||||||
self._threading_warn()
|
self._threading_warn()
|
||||||
name = name or index_name(self.name, columns)
|
name = name or index_name(self.name, columns)
|
||||||
|
|||||||
@ -1,12 +1,7 @@
|
|||||||
try:
|
import six
|
||||||
from urlparse import urlparse
|
|
||||||
except ImportError:
|
|
||||||
from urllib.parse import urlparse
|
|
||||||
|
|
||||||
from collections import OrderedDict, Sequence
|
|
||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
|
from collections import OrderedDict, Sequence
|
||||||
from six import string_types
|
from six.moves.urllib.parse import urlparse
|
||||||
|
|
||||||
|
|
||||||
QUERY_STEP = 1000
|
QUERY_STEP = 1000
|
||||||
@ -60,9 +55,16 @@ class ResultIter(object):
|
|||||||
|
|
||||||
def normalize_column_name(name):
|
def normalize_column_name(name):
|
||||||
"""Check if a string is a reasonable thing to use as a column name."""
|
"""Check if a string is a reasonable thing to use as a column name."""
|
||||||
if not isinstance(name, string_types):
|
if not isinstance(name, six.string_types):
|
||||||
raise ValueError('%r is not a valid column name.' % name)
|
raise ValueError('%r is not a valid column name.' % name)
|
||||||
name = name.strip()
|
|
||||||
|
# limit to 63 characters
|
||||||
|
name = name.strip()[:63]
|
||||||
|
# column names can be 63 *bytes* max in postgresql
|
||||||
|
if isinstance(name, six.text_type):
|
||||||
|
while len(name.encode('utf-8')) >= 64:
|
||||||
|
name = name[:len(name) - 1]
|
||||||
|
|
||||||
if not len(name) or '.' in name or '-' in name:
|
if not len(name) or '.' in name or '-' in name:
|
||||||
raise ValueError('%r is not a valid column name.' % name)
|
raise ValueError('%r is not a valid column name.' % name)
|
||||||
return name
|
return name
|
||||||
@ -70,9 +72,9 @@ def normalize_column_name(name):
|
|||||||
|
|
||||||
def normalize_table_name(name):
|
def normalize_table_name(name):
|
||||||
"""Check if the table name is obviously invalid."""
|
"""Check if the table name is obviously invalid."""
|
||||||
if not isinstance(name, string_types):
|
if not isinstance(name, six.string_types):
|
||||||
raise ValueError("Invalid table name: %r" % name)
|
raise ValueError("Invalid table name: %r" % name)
|
||||||
name = name.strip()
|
name = name.strip()[:63]
|
||||||
if not len(name):
|
if not len(name):
|
||||||
raise ValueError("Invalid table name: %r" % name)
|
raise ValueError("Invalid table name: %r" % name)
|
||||||
return name
|
return name
|
||||||
@ -98,6 +100,6 @@ def ensure_tuple(obj):
|
|||||||
"""Try and make the given argument into a tuple."""
|
"""Try and make the given argument into a tuple."""
|
||||||
if obj is None:
|
if obj is None:
|
||||||
return tuple()
|
return tuple()
|
||||||
if isinstance(obj, Sequence) and not isinstance(obj, string_types):
|
if isinstance(obj, Sequence) and not isinstance(obj, six.string_types):
|
||||||
return tuple(obj)
|
return tuple(obj)
|
||||||
return obj,
|
return obj,
|
||||||
|
|||||||
2
setup.py
2
setup.py
@ -3,7 +3,7 @@ from setuptools import setup, find_packages
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='dataset',
|
name='dataset',
|
||||||
version='1.0.2',
|
version='1.0.3',
|
||||||
description="Toolkit for Python-based database access.",
|
description="Toolkit for Python-based database access.",
|
||||||
long_description="",
|
long_description="",
|
||||||
classifiers=[
|
classifiers=[
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user