From f9cd149ecc46f106697d4e730bade4097ea398ca Mon Sep 17 00:00:00 2001
From: "Committo,Ergo:sum" <esj@rezo.net>
Date: Thu, 2 Mar 2006 22:42:44 +0000
Subject: [PATCH] permettre des exceptions dynamiques pour les tables SQL

---
 ecrire/public/compilo-index.php | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/ecrire/public/compilo-index.php b/ecrire/public/compilo-index.php
index fb5b1032b9..dfe8c409c5 100644
--- a/ecrire/public/compilo-index.php
+++ b/ecrire/public/compilo-index.php
@@ -91,22 +91,19 @@ function index_tables_en_pile($idb, $nom_champ, &$boucles)
 	
 	$excep = $exceptions_des_tables[$r][$nom_champ];
 	if ($excep) {
-			// entite SPIP alias d'un champ SQL
-		if (!is_array($excep)) {
-			$e = $excep;
-			$c = $excep;
-		} 
-			// entite SPIP alias d'un champ dans une jointure
-		else {
+		// entite SPIP alias d'un champ SQL
+		if (is_array($excep)) {
+			// et meme d'un champ dans une jointure
 			if (!$t = array_search($excep[0], $boucles[$idb]->from)) {
 			    $t = 'J' . count($boucles[$idb]->from);
 			    $boucles[$idb]->from[$t] = $excep[0];
 			}
-			$e = $excep[1];
-			$c = $nom_champ;
-			if ($e != $nom_champ) $e .= ' AS '.$c;
+			$excep = $excep[1];
 		}
-		return array("$t.$e", $c);
+		// demander a SQL de gerer le synonyme
+		// ca permet que excep soit dynamique (Cedric, 2/3/06)
+		if ($excep != $nom_champ) $excep .= ' AS '. $nom_champ;
+		return array("$t.$excep", $nom_champ);
 
 	} else {
 		if ($desc['field'][$nom_champ])
-- 
GitLab