sql.py: DbConn.col_info(): Run query with log_level=4 because it gathers information about database structure, and should have the same log_level as other queries that do that
csv2db: Adding indexes: Fixed bug where col.to_Col() could not be used because sql.add_index() does not support name-only columns (plain strings are OK, though)
sql.py: create_table(): has_pkey: Use new TypedCol.constraints to store 'PRIMARY KEY'
sql_gen.py: TypedCol: Added constraints instance var
sql_gen.py: EnsureNotNull: Made coalesce() all uppercase to match how pg_dump spells it
schemas/vegbien.sql: namedplace: Fixed bug where parent_id needed to be included in UNIQUE CONSTRAINT (now UNIQUE INDEX), since there can be more than one e.g. city of the same name if they are in different states
schemas/vegbien.sql: plantname: Changed indexes to use `COALESCE` to match what sql_gen now does
schemas/py_functions.sql: _dateRangeStart, _dateRangeEnd: Changed indexes to use `COALESCE` to match what sql_gen now does
schemas/py_functions.sql: _namePart: Changed indexes to use `COALESCE` to match what sql_gen now does
schemas/functions.sql: _nullIf: Changed indexes to use `COALESCE` to match what sql_gen now does
schemas/functions.sql: _nullIf: Require a non-NULL null-equivalent value
schemas/functions.sql: _label: Changed indexes to use `COALESCE` to match what sql_gen now does
schemas/functions.sql: _label: Require a non-NULL label
sql_gen.py: null_sentinels: Removed types where a sentinel doesn't make sense (unknown types, boolean) because types with no sentinel are now handled gracefully by users of ensure_not_null()
sql.py: add_index(): ensure_not_null: Handle unknown types gracefully
sql_gen.py: MockDb: Added col_info()
sql_gen.py: Use as_*() functions where the auto-wrapping was previously done manually
sql_gen.py: CompareCond.to_str(): Use ensure_not_null()'s new type_ param to apply same function to both sides but not if the right side is already NOT NULL
sql_gen.py: null_sentinels: Added value for character varying type
sql_gen.py: ensure_not_null(): Support non-column inputs if type_ is set
sql_gen.py: null_sentinels: Added value for USER-DEFINED type
sql.py: mk_select(): Joins: Filtering on no match: Use '~=' sql_gen.CompareCond operator so that IS NULL is always used, regardless of the not-null column's nullability
sql_gen.py: null_sentinels: Added value for boolean type
sql_gen.py: ensure_not_null(): Added type_ param to override the underlying column's type
sql_gen.py: EnsureNotNull: Take a type param instead of a null param so that the EnsureNotNull object stores the underlying column's type
sql_gen.py: underlying_col(): Support non-Col inputs
sql_gen.py: EnsureNotNull: Removed default value for null param to remind user that default value depends on value's type and will not always be a string
sql.py: add_index(): Added ensure_not_null param to disable the ensure_not_null functionality to force a plain index
sql.py: flatten(): Add indexes on the created table so its columns can be used in an O(n) merge join
sql_gen.py: null_sentinels: Added value for integer type
sql_gen.py: CompareCond.to_str(): Always wrap the left-side column if it's nullable. Wrap the right-side value if the left side was wrapped, rather than if both the left and right side are nullable. This causes coalesce() indexes to be used to look up NULL values using the value NULL gets coalesced to, rather than doing a sequential scan.
sql_gen.py: Run truncate() on all identifiers so that literal-string-based lookups for an identifier (such as in db.col_info()) don't use the untruncated value
sql_gen.py: Added truncate()
sql.py: put_table(): Resolving default value column: Fixed bug where default value of None was used as a key for mapping, even though this is an invalid Col name
sql_gen.py: ensure_not_null(): If input column cannot be ensured to be NULL, pass any raised exception through rather than suppressing it and leaving the column in a nullable state
schemas/functions.sql: _merge: Changed indexes to use `COALESCE` to match what sql_gen now does
schemas/functions.sql: _alt: Changed indexes to use `COALESCE` to match what sql_gen now does
sql_gen.py: CompareCond.to_str(): Handle nullable columns using ensure_not_null()
sql_gen.py: ensure_not_null(): Raise NoUnderlyingTableException if can't ensure not null for that reason
sql_gen.py: is_underlying_table(): Support non-Table inputs
sql_gen.py: NamedValues: Call set_cols_table() with the created table, not just the name, so that is_underlying_table() works properly
sql_gen.py: underlying_col(): If no underlying table, raise NoUnderlyingTableException
sql_gen.py: Added is_underlying_table()
sql_gen.py: ensure_not_null(): Call underlying_col() on the column to remove all renamings
sql_gen.py: Added underlying_col()
sql_gen.py: Join.to_str(): join(): Removed no longer needed `*_table = *_table.to_Table()`
sql_gen.py: Col: Support Table objects that are not just names, by calling `.to_Table()` on the table before stringifying it
sql_gen.py: ensure_not_null(): Added ignore_unknown_type param
sql_gen.py: CompareCond.to_str(): Put handling nullable columns as a separate step so it can be expanded
csv2db: Errors table: Removed no longer needed sql_gen.EnsureNotNull() because this is now added automatically
sql.py: add_index(): Handle nullable columns by using sql_gen.ensure_not_null() to automatically add a coalesce() wrapper where needed
sql_gen.py: Added ensure_not_null()
sql.py: DbConn.col_info(): Fixed bug where is_nullable needed to be cast to a boolean
sql.py: cast(): Support string column name inputs
sql.py: DbConn: Renamed col_default() to col_info() and have it return a sql_gen.TypedCol object containing all the TypedCol info about the column, not just the default value
sql_gen.py: TypedCol: Added default and nullable params
dicts.py: Import util after items that util depends on have been defined, to avoid unsatisfied circular dependency
sql.py: DbConn.col_default(): Pass the connection to sql_gen.as_Code() so it fixes the syntax on values returned by PostgreSQL
sql_gen.py: as_Code(): Added optional db param, which causes the function to run db.std_code() on the value to fix the syntax
sql.py: DbConn: Added std_code()
db_xml.py: Removed into_table_name() because this functionality is now handled by sql.into_table_name()
sql.py: into_table_name(): Also parse hierarchical tables (mappings with a rank column) using a special syntax
sql.py: put_table(): Fixed bug where distinct_on included columns that were not in the input table, and were thus incorrectly taken from the LEFT JOINed output table
sql.py: track_data_error(): Do nothing if cols are empty, because mk_track_data_error() requires at least one col. mk_track_data_error(): Assert that cols are not empty because VALUES clause requires at least one row.
bin/map: by_col: Pass on_error to db_xml.put_table() that calls ex_tracker.track()
sql.py: put_table(): No handler for exception: Pass exception to on_error() instead of raising a warning, so that error message can be formatted
db_xml.py: put_table(): Pass on_error to sql.put_table()
db_xml.py: put_table(): Take on_error param like row-based put()
sql.py: put_table(): Take on_error param
sql.py: get_cur_query(): Removed no longer used input_params parameter
sql.py: Removed unused mogrify()
sql.py: DbConn.DbCursor.execute(): Removed no longer used params parameter
sql.py: with_autocommit(): Use isolation_level attr and set_isolation_level() method of connection instead of autocommit attr to support older versions of psycopg2
sql.py: DbConn.DbCursor.execute(): Only fetch all rows for empty SELECT query, to support older versions of Python that would give a "no results to fetch" error for other types of queries
csv2db: When reraising exception, use `raise` instead of `raise e` to preserve whole stack trace
sql.py: Removed no longer used _query_lookup()
sql.py: DbConn: Cache queries without params, as params are no longer used
sql.py: DbConn.is_cached(): Removed no longer used params parameter
sql.py: Removed no longer used run_raw_query()
sql.py: run_query(): Call db.run_query() directly instead of via run_raw_query()
sql.py: DbConn.run_query(): Removed no longer used params parameter
sql.py: DbConn._db(): Setting search_path: Use esc_value() instead of params
sql.py: run_query(): Removed no longer used params parameter
sql.py: run_query_into(): Moved main case (into != None) outside of if statement because the special-case if statement contains `return`
sql.py: run_query_into(): Removed no longer used params parameter
sql.py: mk_insert_select(): Removed no longer used params parameter
sql.py: mk_insert_select(): Return just the query instead of the query plus empty params
sql.py: mk_select(): Return just the query instead of the query plus empty params
sql.py: tables(): Use select() instead of a custom run_query() to avoid using params, which will be deprecated to make it easier to support old versions of Python
sql.py: DbConn.DbCursor.execute(): Require that params are empty, to ensure that code uses db.esc_value() instead. This keeps literal values in the same place as the rest of the query, so that they do not need to be maintained and passed around separately in a params list.
sql.py: constraint_cols(): Use db.esc_value() instead of params
sql.py: index_cols(): Use db.esc_value() instead of params
sql.py: add_pkey(): Use simpler `ADD PRIMARY KEY` syntax to avoid having to create a name for the primary key
db_xml.py: put_table(): Subsetting in_table: Add pkey to created temp table to facilitate joining it with intermediate tables
schemas/postgresql.nimoy.conf: shared_buffers: Fixed syntax error where decimals were not supported
sql.py: truncate(): Re-added support for string tables using sql_gen.as_Table(). This fixes empty_db(), which relied on this functionality.
sql_gen.py: as_Table(): Added schema param to use as default schema
inputs/SALVIAS: Switched to using CSV exports of the DB, so that staging tables could be created for column-based import