Walter Dörwald avatar Walter Dörwald committed 9a171d5

Backport ll.orasql.PrimaryKey.itercolumns() from the upcoming 3.8.

Comments (0)

Files changed (3)

+Changes in 3.7.5 (released 04/19/2010)
+--------------------------------------
+
+*	:class:`ll.orasql.PrimaryKey` has a new method :meth:`itercolumns` that
+	returns an iterator over the columns this primary key consists of.
+
+
+
 Changes in 3.7.4 (released 03/25/2010)
 --------------------------------------
 
 
 args = dict(
 	name="ll-xist",
-	version="3.7.4",
+	version="3.7.5",
 	description="Extensible HTML/XML generator, cross-platform templating language, Oracle utilities and various other tools",
 	long_description=descr,
 	author="Walter Doerwald",

src/ll/orasql/__init__.py

 	"""
 	type = u"pk"
 
+	def itercolumns(self, connection=None):
+		"""
+		Return an iterator over the columns this primary key consists of.
+		"""
+		(connection, cursor) = self.getcursor(connection)
+		cursor.execute("select decode(owner, user, null, owner) as owner, constraint_name, table_name, r_owner, r_constraint_name from all_constraints where constraint_type='P' and owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name)
+		rec2 = cursor.fetchone()
+		if rec2 is None:
+			raise SQLObjectNotFoundError(self)
+		tablename = getfullname(rec2.table_name, rec2.owner)
+		cursor.execute("select column_name from all_cons_columns where owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name)
+		for r in cursor:
+			yield Column(u"{0}.{1}".format(tablename, r.column_name))
+
 	def createddl(self, connection=None, term=True):
 		(connection, cursor) = self.getcursor(connection)
 		cursor.execute("select decode(owner, user, null, owner) as owner, constraint_name, table_name, r_owner, r_constraint_name from all_constraints where constraint_type='P' and owner=nvl(:owner, user) and constraint_name=:name", owner=self.owner, name=self.name)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.