From: Billy G. A. <bal...@us...> - 2003-06-17 01:49:27
|
Update of /cvsroot/pypgsql/pypgsql/pyPgSQL In directory sc8-pr-cvs1:/tmp/cvs-serv7227/pyPgSQL Modified Files: PgSQL.py Log Message: 05JUN2003 bga - Change the name of the quoting function back to _quote. Variables named like __*__ should be restrict to system names. 02JUN2003 bga - PgTypes is now hashable. repr() of a PgType will now return the repr() of the underlying OID. - Connection.binary() will now fail if autocommit is enabled. - Connection.binary() will no longer commit the transaction after creating the large object. The application developer is now responsible for commiting (or for rolling back) the transaction [Bug #747525]. - Added PG_TIMETZ to the mix [Patch #708013]. - Pg_Money will now accept a string as a parameter. - PostgreSQL int2, int, int4 will now be cast into Python ints. Int8 will be cast into a Python long. Float4, float8, and money types will be cast into a Python float. Index: PgSQL.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL/PgSQL.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** PgSQL.py 7 Mar 2003 06:24:39 -0000 1.32 --- PgSQL.py 17 Jun 2003 01:49:24 -0000 1.33 *************** *** 30,33 **** --- 30,50 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 05JUN2003 bga - Change the name of the quoting function back to | + # _quote. Variables named like __*__ should be restrict | + # to system names. | + # 02JUN2003 bga - PgTypes is now hashable. repr() of a PgType will now | + # return the repr() of the underlying OID. | + # - Connection.binary() will now fail if autocommit is | + # enabled. | + # - Connection.binary() will no longer commit the trans- | + # action after creating the large object. The applica- | + # tion developer is now responsible for commiting (or | + # for rolling back) the transaction [Bug #747525]. | + # - Added PG_TIMETZ to the mix [Patch #708013]. | + # - Pg_Money will now accept a string as a parameter. | + # - PostgreSQL int2, int, int4 will now be cast into | + # Python ints. Int8 will be cast into a Python long. | + # Float4, float8, and money types will be cast into | + # a Python float. | # 07MAR2003 bga - Correct problem with the PgNumeric.__radd__ method. | # [Bug #694358] | *************** *** 447,452 **** BINARY = DBAPITypeObject('BINARY', PG_OID, PG_BLOB, PG_BYTEA) ! DATETIME = DBAPITypeObject('DATETIME', PG_DATE, PG_TIME, PG_TIMESTAMP, ! PG_TIMESTAMPTZ, PG_ABSTIME, PG_RELTIME, PG_INTERVAL, PG_TINTERVAL) --- 464,470 ---- BINARY = DBAPITypeObject('BINARY', PG_OID, PG_BLOB, PG_BYTEA) ! DATETIME = DBAPITypeObject('DATETIME', PG_DATE, PG_TIME, PG_TIMETZ, ! PG_TIMESTAMP, PG_TIMESTAMPTZ, ! PG_ABSTIME, PG_RELTIME, PG_INTERVAL, PG_TINTERVAL) *************** *** 492,496 **** def __repr__(self): ! return PQftypeName(self.value) def __str__(self): --- 510,514 ---- def __repr__(self): ! return repr(self.value) def __str__(self): *************** *** 547,551 **** # Convert any years using 365.2425 days per year, which is PostgreSQL's ! # 's assumption about the number of days in a year. if len(ydh) > 1: if ydh[1].lower().startswith('year'): --- 565,569 ---- # Convert any years using 365.2425 days per year, which is PostgreSQL's ! # assumption about the number of days in a year. if len(ydh) > 1: if ydh[1].lower().startswith('year'): *************** *** 738,742 **** return value else: ! return PgInt2(value) elif _ftv == PG_INT4: if type(value) is IntType: --- 756,760 ---- return value else: ! return int(value) elif _ftv == PG_INT4: if type(value) is IntType: *************** *** 751,755 **** if type(value) is PgInt8Type: return value ! return PgInt8(value) elif _ftv == PG_NUMERIC: if isinstance(value, PgNumeric): --- 769,773 ---- if type(value) is PgInt8Type: return value ! return long(value) elif _ftv == PG_NUMERIC: if isinstance(value, PgNumeric): *************** *** 769,773 **** return value else: ! return PgMoney(value) elif _ftv == DATETIME: if type(value) in [DateTimeType, DateTimeDeltaType]: --- 787,791 ---- return value else: ! return PgMoney(value).value elif _ftv == DATETIME: if type(value) in [DateTimeType, DateTimeDeltaType]: *************** *** 791,795 **** return value else: ! return PgOther(value) elif self.__conn.unicode_results \ and _ftv in (PG_CHAR, PG_BPCHAR, PG_TEXT, PG_VARCHAR, PG_NAME): --- 809,813 ---- return value else: ! return value elif self.__conn.unicode_results \ and _ftv in (PG_CHAR, PG_BPCHAR, PG_TEXT, PG_VARCHAR, PG_NAME): *************** *** 974,978 **** # NOTE: A PgOther object will use the PgQuoteString() function in libpq. ! def __quote__(self, forArray=0): if self.value: return PgQuoteString(self.value, forArray) --- 992,996 ---- # NOTE: A PgOther object will use the PgQuoteString() function in libpq. ! def _quote(self, forArray=0): if self.value: return PgQuoteString(self.value, forArray) *************** *** 1138,1142 **** # NOTE: A PgArray object will use the _handleArray() function to quote # itself. ! def __quote__(self, forArray=0): if self.value: return _handleArray(self.value) --- 1156,1160 ---- # NOTE: A PgArray object will use the _handleArray() function to quote # itself. ! def _quote(self, forArray=0): if self.value: return _handleArray(self.value) *************** *** 1244,1248 **** # NOTE: A PgBytea object will use the PgQuoteBytea() function in libpq ! def __quote__(self, forArray=0): if self.value: return PgQuoteBytea(self.value, forArray) --- 1262,1266 ---- # NOTE: A PgBytea object will use the PgQuoteBytea() function in libpq ! def _quote(self, forArray=0): if self.value: return PgQuoteBytea(self.value, forArray) *************** *** 1631,1635 **** return PgNumeric(-self.__v, self.__p, self.__s) ! def __quote__(self, forArray=0): if self.__v: if forArray: --- 1649,1653 ---- return PgNumeric(-self.__v, self.__p, self.__s) ! def _quote(self, forArray=0): if self.__v: if forArray: *************** *** 1678,1682 **** return ! self.value = float(value) if self.value < -21474836.48 or self.value > 21474836.47: raise OverflowError, 'money initialization' --- 1696,1709 ---- return ! if type(value) is StringType: ! if value[0] == '(': ! self.value = PgMoney(-float(replace(value[2:-1], ',', ''))) ! elif value[0] == '-': ! self.value = PgMoney(-float(replace(value[2:], ',', ''))) ! else: ! self.value = PgMoney(float(replace(value[1:], ',', ''))) ! else: ! self.value = float(value) ! if self.value < -21474836.48 or self.value > 21474836.47: raise OverflowError, 'money initialization' *************** *** 1777,1781 **** return '$%s' % _s ! def __quote__(self, forArray=0): if self.value: if forArray: --- 1804,1808 ---- return '$%s' % _s ! def _quote(self, forArray=0): if self.value: if forArray: *************** *** 1940,1944 **** return str(self.value) ! def __quote__(self, forArray=0): if self.value is not None: s = str(self.value) --- 1967,1971 ---- return str(self.value) ! def _quote(self, forArray=0): if self.value is not None: s = str(self.value) *************** *** 2185,2190 **** elif isinstance(_i, PgArray): _j = _j + _handleArray(_i)[1:-1] + ',' - elif hasattr(_i, '__quote__'): - _j = '%s%s,' % (_j, _i.__quote__(1)) elif hasattr(_i, '_quote'): _j = '%s%s,' % (_j, _i._quote(1)) --- 2212,2215 ---- *************** *** 2212,2217 **** if value is None: return 'NULL' - elif hasattr(value, '__quote__'): - return value.__quote__() elif hasattr(value, '_quote'): return value._quote() --- 2237,2240 ---- *************** *** 2533,2536 **** --- 2556,2563 ---- "Creation of large object failed - Connection is not open." + if self.autocommit: + raise InterfaceError, \ + "Creation of large object failed - autocommit is on." + _nl = len(self.notices) _ct = 0 *************** *** 2554,2561 **** self.conn.query("ROLLBACK WORK") raise Warning, self.conn.notices.pop() - - if self.inTransaction: - if _ct: # Only commit the transaction if we started it. - self.conn.query("COMMIT WORK") return _lo --- 2581,2584 ---- |