Renamed technology tables and views

* Removed the _v2 suffix from some tables and views.
This commit is contained in:
Emmanuel BENOîT 2012-04-09 15:01:04 +02:00
parent ab04752169
commit 071257786c
19 changed files with 82 additions and 82 deletions

View file

@ -29,7 +29,7 @@ class PlayerTechnologiesDAOBean
{ {
/** SQL query that fetches an empire's research state */ /** SQL query that fetches an empire's research state */
private static final String Q_EMPIRE_RESEARCH = "SELECT * FROM emp.technologies_v2_view WHERE empire_id = ?"; private static final String Q_EMPIRE_RESEARCH = "SELECT * FROM emp.technologies_view WHERE empire_id = ?";
/** Row mapper for research state entries */ /** Row mapper for research state entries */
private final ResearchRowMapper mResearch; private final ResearchRowMapper mResearch;

View file

@ -101,7 +101,7 @@ CREATE TYPE emp.technology_state
* research system has been removed * research system has been removed
*/ */
CREATE TABLE emp.technologies_v2( CREATE TABLE emp.technologies(
/* Identifier of the empire */ /* Identifier of the empire */
empire_id INT NOT NULL , empire_id INT NOT NULL ,
@ -136,9 +136,9 @@ CREATE TABLE emp.technologies_v2(
); );
CREATE INDEX idx_emptech_technology CREATE INDEX idx_emptech_technology
ON emp.technologies_v2 ( technology_name_id ); ON emp.technologies ( technology_name_id );
ALTER TABLE emp.technologies_v2 ALTER TABLE emp.technologies
ADD CONSTRAINT fk_emptech_empire ADD CONSTRAINT fk_emptech_empire
FOREIGN KEY ( empire_id ) REFERENCES emp.empires ( name_id ) FOREIGN KEY ( empire_id ) REFERENCES emp.empires ( name_id )
ON DELETE CASCADE , ON DELETE CASCADE ,

View file

@ -140,7 +140,7 @@ BEGIN
FROM defs.technologies _def FROM defs.technologies _def
LEFT OUTER JOIN ( LEFT OUTER JOIN (
SELECT technology_name_id SELECT technology_name_id
FROM emp.technologies_v2 _tech FROM emp.technologies _tech
WHERE technology_name_id = _name_id WHERE technology_name_id = _name_id
AND emptech_state = 'RESEARCH' AND emptech_state = 'RESEARCH'
FOR UPDATE OF _tech FOR UPDATE OF _tech
@ -173,7 +173,7 @@ BEGIN
-- Update empire research if necessary -- Update empire research if necessary
IF _old_points <> _points THEN IF _old_points <> _points THEN
_multi := _points::DOUBLE PRECISION / _old_points::DOUBLE PRECISION; _multi := _points::DOUBLE PRECISION / _old_points::DOUBLE PRECISION;
UPDATE emp.technologies_v2 UPDATE emp.technologies
SET emptech_points = emptech_points * _multi SET emptech_points = emptech_points * _multi
WHERE technology_name_id = _name_id WHERE technology_name_id = _name_id
AND emptech_points IS NOT NULL; AND emptech_points IS NOT NULL;

View file

@ -46,7 +46,7 @@ BEGIN
SELECT _name_id , resource_name_id FROM defs.resources; SELECT _name_id , resource_name_id FROM defs.resources;
-- Insert technologies that have no dependencies as research in progress -- Insert technologies that have no dependencies as research in progress
INSERT INTO emp.technologies_v2 ( empire_id , technology_name_id ) INSERT INTO emp.technologies ( empire_id , technology_name_id )
SELECT _name_id , technology_name_id SELECT _name_id , technology_name_id
FROM defs.technologies FROM defs.technologies
LEFT OUTER JOIN defs.technology_dependencies LEFT OUTER JOIN defs.technology_dependencies

View file

@ -38,7 +38,7 @@ BEGIN
SELECT INTO _impl_data SELECT INTO _impl_data
technology_name_id , technology_price technology_name_id , technology_price
FROM emp.empires _emp FROM emp.empires _emp
INNER JOIN emp.technologies_v2 _tech INNER JOIN emp.technologies _tech
ON _tech.empire_id = _emp.name_id ON _tech.empire_id = _emp.name_id
INNER JOIN defs.technologies _def INNER JOIN defs.technologies _def
USING ( technology_name_id ) USING ( technology_name_id )
@ -58,25 +58,25 @@ BEGIN
UPDATE emp.empires UPDATE emp.empires
SET cash = cash - _impl_data.technology_price SET cash = cash - _impl_data.technology_price
WHERE name_id = _empire; WHERE name_id = _empire;
UPDATE emp.technologies_v2 UPDATE emp.technologies
SET emptech_state = 'KNOWN' SET emptech_state = 'KNOWN'
WHERE empire_id = _empire WHERE empire_id = _empire
AND technology_name_id = _impl_data.technology_name_id; AND technology_name_id = _impl_data.technology_name_id;
-- Insert new research -- Insert new research
INSERT INTO emp.technologies_v2 ( empire_id , technology_name_id ) INSERT INTO emp.technologies ( empire_id , technology_name_id )
SELECT _empire , _valid.technology_name_id SELECT _empire , _valid.technology_name_id
FROM ( SELECT _tech.technology_name_id , FROM ( SELECT _tech.technology_name_id ,
( COUNT(*) = COUNT(_emptech.emptech_state) ) AS emptech_has_dependencies ( COUNT(*) = COUNT(_emptech.emptech_state) ) AS emptech_has_dependencies
FROM defs.technologies _tech FROM defs.technologies _tech
INNER JOIN defs.technology_dependencies _deps INNER JOIN defs.technology_dependencies _deps
USING ( technology_name_id ) USING ( technology_name_id )
LEFT OUTER JOIN emp.technologies_v2 _emptech LEFT OUTER JOIN emp.technologies _emptech
ON _emptech.technology_name_id = _deps.technology_name_id_depends ON _emptech.technology_name_id = _deps.technology_name_id_depends
AND _emptech.emptech_state = 'KNOWN' AND _emptech.emptech_state = 'KNOWN'
AND _emptech.empire_id = _empire AND _emptech.empire_id = _empire
GROUP BY _tech.technology_name_id ) _valid GROUP BY _tech.technology_name_id ) _valid
LEFT OUTER JOIN emp.technologies_v2 _emptech LEFT OUTER JOIN emp.technologies _emptech
ON _emptech.empire_id = _empire ON _emptech.empire_id = _empire
AND _emptech.technology_name_id = _valid.technology_name_id AND _emptech.technology_name_id = _valid.technology_name_id
WHERE _emptech.empire_id IS NULL AND _valid.emptech_has_dependencies; WHERE _emptech.empire_id IS NULL AND _valid.emptech_has_dependencies;
@ -177,7 +177,7 @@ BEGIN
emp.technology_make_identifier( empire_id , _str.name , emptech_visible ) , emp.technology_make_identifier( empire_id , _str.name , emptech_visible ) ,
_etech.emptech_priority _etech.emptech_priority
FROM emp.empires _emp FROM emp.empires _emp
INNER JOIN emp.technologies_v2 _etech INNER JOIN emp.technologies _etech
ON _etech.empire_id = _emp.name_id ON _etech.empire_id = _emp.name_id
AND _etech.emptech_state = 'RESEARCH' AND _etech.emptech_state = 'RESEARCH'
INNER JOIN defs.technologies _tech INNER JOIN defs.technologies _tech
@ -270,7 +270,7 @@ CREATE FUNCTION emp.resprio_update_apply( )
AS $resprio_update_apply$ AS $resprio_update_apply$
BEGIN BEGIN
UPDATE emp.technologies_v2 UPDATE emp.technologies
SET emptech_priority = _emptech_priority SET emptech_priority = _emptech_priority
FROM rprio_update FROM rprio_update
WHERE _empire_id = empire_id WHERE _empire_id = empire_id
@ -367,7 +367,7 @@ CREATE VIEW emp.technology_visibility_view
OR emptech_points >= sys.get_constant( 'game.research.visibility.points' ) OR emptech_points >= sys.get_constant( 'game.research.visibility.points' )
OR emptech_points / technology_points::DOUBLE PRECISION >= sys.get_constant( 'game.research.visibility.ratio' ) OR emptech_points / technology_points::DOUBLE PRECISION >= sys.get_constant( 'game.research.visibility.ratio' )
) AS emptech_visible ) AS emptech_visible
FROM emp.technologies_v2 FROM emp.technologies
INNER JOIN defs.technologies INNER JOIN defs.technologies
USING ( technology_name_id ); USING ( technology_name_id );
@ -390,7 +390,7 @@ CREATE VIEW emp.research_weights_view
AS SELECT empire_id , technology_name_id , AS SELECT empire_id , technology_name_id ,
POW( sys.get_constant( 'game.research.weightBase' ) , POW( sys.get_constant( 'game.research.weightBase' ) ,
emptech_priority ) AS emptech_weight emptech_priority ) AS emptech_weight
FROM emp.technologies_v2 FROM emp.technologies
WHERE emptech_state = 'RESEARCH'; WHERE emptech_state = 'RESEARCH';
/* /*
@ -450,8 +450,8 @@ CREATE VIEW emp.research_total_weights_view
* technology_buildings The buildings which are unlocked when the * technology_buildings The buildings which are unlocked when the
* technology is implemented * technology is implemented
*/ */
DROP VIEW IF EXISTS emp.technologies_v2_view CASCADE; DROP VIEW IF EXISTS emp.technologies_view CASCADE;
CREATE VIEW emp.technologies_v2_view CREATE VIEW emp.technologies_view
AS SELECT empire_id , AS SELECT empire_id ,
emp.technology_make_identifier( empire_id , _name_str.name , emptech_visible ) AS emptech_id , emp.technology_make_identifier( empire_id , _name_str.name , emptech_visible ) AS emptech_id ,
emptech_state , emptech_state ,
@ -497,7 +497,7 @@ CREATE VIEW emp.technologies_v2_view
ELSE ELSE
'' ''
END ) AS technology_buildings END ) AS technology_buildings
FROM emp.technologies_v2 FROM emp.technologies
INNER JOIN emp.technology_visibility_view INNER JOIN emp.technology_visibility_view
USING ( technology_name_id , empire_id ) USING ( technology_name_id , empire_id )
INNER JOIN defs.technologies _tech INNER JOIN defs.technologies _tech
@ -514,5 +514,5 @@ CREATE VIEW emp.technologies_v2_view
ON _descr_str.id = _tech.technology_description_id; ON _descr_str.id = _tech.technology_description_id;
GRANT SELECT GRANT SELECT
ON emp.technologies_v2_view ON emp.technologies_view
TO :dbuser; TO :dbuser;

View file

@ -479,7 +479,7 @@ AS $$
UNION SELECT bv.* UNION SELECT bv.*
FROM tech.buildings_view bv FROM tech.buildings_view bv
INNER JOIN emp.planets ep ON ep.planet_id = $1 INNER JOIN emp.planets ep ON ep.planet_id = $1
INNER JOIN emp.technologies_v2 _emptech INNER JOIN emp.technologies _emptech
USING ( technology_name_id , empire_id ) USING ( technology_name_id , empire_id )
WHERE emptech_state = 'KNOWN' WHERE emptech_state = 'KNOWN'
) AS bv , ( ) AS bv , (
@ -530,7 +530,7 @@ AS $$
UNION SELECT bv.* UNION SELECT bv.*
FROM tech.ships_view bv FROM tech.ships_view bv
INNER JOIN emp.planets ep ON ep.planet_id = $1 INNER JOIN emp.planets ep ON ep.planet_id = $1
INNER JOIN emp.technologies_v2 t INNER JOIN emp.technologies t
USING ( empire_id , technology_name_id ) USING ( empire_id , technology_name_id )
WHERE emptech_state = 'KNOWN' WHERE emptech_state = 'KNOWN'
) AS bv , ( ) AS bv , (
@ -712,7 +712,7 @@ BEGIN
FROM tech.ships s FROM tech.ships s
INNER JOIN tech.buildables b INNER JOIN tech.buildables b
ON b.name_id = s.buildable_id ON b.name_id = s.buildable_id
LEFT OUTER JOIN emp.technologies_v2 t LEFT OUTER JOIN emp.technologies t
ON t.empire_id = e_id AND t.technology_name_id = b.technology_name_id ON t.empire_id = e_id AND t.technology_name_id = b.technology_name_id
AND t.emptech_state = 'KNOWN' AND t.emptech_state = 'KNOWN'
WHERE s.buildable_id = s_id; WHERE s.buildable_id = s_id;
@ -778,7 +778,7 @@ BEGIN
FROM tech.buildings s FROM tech.buildings s
INNER JOIN tech.buildables b INNER JOIN tech.buildables b
ON b.name_id = s.buildable_id ON b.name_id = s.buildable_id
LEFT OUTER JOIN emp.technologies_v2 t LEFT OUTER JOIN emp.technologies t
ON t.empire_id = e_id AND t.technology_name_id = b.technology_name_id ON t.empire_id = e_id AND t.technology_name_id = b.technology_name_id
AND t.emptech_state = 'KNOWN' AND t.emptech_state = 'KNOWN'
WHERE s.buildable_id = b_id; WHERE s.buildable_id = b_id;

View file

@ -1198,7 +1198,7 @@ GRANT SELECT ON bugs.dump_main_view TO :dbuser;
CREATE VIEW bugs.dump_research_view CREATE VIEW bugs.dump_research_view
AS SELECT et.empire_id , tst.name AS name , et.emptech_state AS state , AS SELECT et.empire_id , tst.name AS name , et.emptech_state AS state ,
et.emptech_points AS points , et.emptech_priority AS priority et.emptech_points AS points , et.emptech_priority AS priority
FROM emp.technologies_v2 et FROM emp.technologies et
INNER JOIN defs.strings tst ON tst.id = et.technology_name_id; INNER JOIN defs.strings tst ON tst.id = et.technology_name_id;
GRANT SELECT ON bugs.dump_research_view TO :dbuser; GRANT SELECT ON bugs.dump_research_view TO :dbuser;

View file

@ -60,7 +60,7 @@ AS $gu_research_get_empires$
USING ( updtgt_id , updtype_id , update_id ) USING ( updtgt_id , updtype_id , update_id )
INNER JOIN emp.empires _empire INNER JOIN emp.empires _empire
USING ( name_id ) USING ( name_id )
INNER JOIN emp.technologies_v2 _emp_tech INNER JOIN emp.technologies _emp_tech
ON _emp_tech.empire_id = _empire.name_id ON _emp_tech.empire_id = _empire.name_id
INNER JOIN defs.technologies _tech INNER JOIN defs.technologies _tech
USING ( technology_name_id ) USING ( technology_name_id )
@ -121,7 +121,7 @@ BEGIN
SELECT _emp_tech.technology_name_id , _emp_tech.emptech_points , _emp_tech.emptech_priority , SELECT _emp_tech.technology_name_id , _emp_tech.emptech_points , _emp_tech.emptech_priority ,
_points * _weights.emptech_weight / ( _totals.emptech_total_weight * 1440 ) AS emptech_new_points , _points * _weights.emptech_weight / ( _totals.emptech_total_weight * 1440 ) AS emptech_new_points ,
_def.technology_points::DOUBLE PRECISION AS technology_points _def.technology_points::DOUBLE PRECISION AS technology_points
FROM emp.technologies_v2 _emp_tech FROM emp.technologies _emp_tech
INNER JOIN emp.research_weights_view _weights INNER JOIN emp.research_weights_view _weights
USING ( empire_id , technology_name_id ) USING ( empire_id , technology_name_id )
INNER JOIN emp.research_total_weights_view _totals INNER JOIN emp.research_total_weights_view _totals
@ -133,7 +133,7 @@ BEGIN
LOOP LOOP
IF _record.emptech_points + _record.emptech_new_points >= _record.technology_points THEN IF _record.emptech_points + _record.emptech_new_points >= _record.technology_points THEN
UPDATE emp.technologies_v2 UPDATE emp.technologies
SET emptech_state = 'PENDING' , SET emptech_state = 'PENDING' ,
emptech_points = NULL , emptech_points = NULL ,
emptech_priority = NULL emptech_priority = NULL
@ -141,7 +141,7 @@ BEGIN
AND empire_id = _empire; AND empire_id = _empire;
ELSE ELSE
UPDATE emp.technologies_v2 UPDATE emp.technologies
SET emptech_points = emptech_points + _record.emptech_new_points SET emptech_points = emptech_points + _record.emptech_new_points
WHERE technology_name_id = _record.technology_name_id WHERE technology_name_id = _record.technology_name_id
AND empire_id = _empire; AND empire_id = _empire;

View file

@ -24,11 +24,11 @@ BEGIN;
); );
/* Remove foreign key to empires on empire technologies */ /* Remove foreign key to empires on empire technologies */
ALTER TABLE emp.technologies_v2 ALTER TABLE emp.technologies
DROP CONSTRAINT fk_emptech_empire; DROP CONSTRAINT fk_emptech_empire;
/* Insert records for the new technology, with different states */ /* Insert records for the new technology, with different states */
INSERT INTO emp.technologies_v2 ( INSERT INTO emp.technologies (
empire_id , technology_name_id , emptech_state , empire_id , technology_name_id , emptech_state ,
emptech_points , emptech_priority emptech_points , emptech_priority
) VALUES ( ) VALUES (
@ -46,7 +46,7 @@ BEGIN;
SELECT diag_test_name( 'defs.uoc_technology() - Update - Scaling of in-progress research' ); SELECT diag_test_name( 'defs.uoc_technology() - Update - Scaling of in-progress research' );
SELECT set_eq( $$ SELECT set_eq( $$
SELECT empire_id , ROUND( emptech_points )::INT SELECT empire_id , ROUND( emptech_points )::INT
FROM emp.technologies_v2 FROM emp.technologies
WHERE emptech_state = 'RESEARCH' WHERE emptech_state = 'RESEARCH'
$$ , $$ VALUES( $$ , $$ VALUES(
1 , 500 1 , 500

View file

@ -117,7 +117,7 @@ BEGIN;
SELECT diag_test_name( 'emp.create_empire() - Empire technologies have been initialised' ); SELECT diag_test_name( 'emp.create_empire() - Empire technologies have been initialised' );
SELECT set_eq( $$ SELECT set_eq( $$
SELECT technology_name_id , emptech_state::TEXT , emptech_points , emptech_priority SELECT technology_name_id , emptech_state::TEXT , emptech_points , emptech_priority
FROM emp.technologies_v2 FROM emp.technologies
WHERE empire_id = _get_emp_name( 'testEmp1' ); WHERE empire_id = _get_emp_name( 'testEmp1' );
$$ , $$ VALUES( $$ , $$ VALUES(
_get_string( 'tech1' ) , 'RESEARCH' , 0.0 , 2 _get_string( 'tech1' ) , 'RESEARCH' , 0.0 , 2

View file

@ -36,20 +36,20 @@ BEGIN;
( _get_string( 'tech3' ) , _get_string( 'tech2' ) ); ( _get_string( 'tech3' ) , _get_string( 'tech2' ) );
/* Empire "emp1" has only in-progress research. */ /* Empire "emp1" has only in-progress research. */
INSERT INTO emp.technologies_v2 ( empire_id , technology_name_id ) INSERT INTO emp.technologies ( empire_id , technology_name_id )
VALUES( _get_emp_name( 'emp1' ) , _get_string( 'tech1' ) ); VALUES( _get_emp_name( 'emp1' ) , _get_string( 'tech1' ) );
/* Empire "emp2" has a pending technology. */ /* Empire "emp2" has a pending technology. */
INSERT INTO emp.technologies_v2 ( empire_id , technology_name_id , emptech_state , emptech_points , emptech_priority ) INSERT INTO emp.technologies ( empire_id , technology_name_id , emptech_state , emptech_points , emptech_priority )
VALUES( _get_emp_name( 'emp2' ) , _get_string( 'tech1' ) , 'PENDING' , NULL , NULL ); VALUES( _get_emp_name( 'emp2' ) , _get_string( 'tech1' ) , 'PENDING' , NULL , NULL );
/* Empire "emp3" has implemented 'tech1' and has 'tech2' as pending. */ /* Empire "emp3" has implemented 'tech1' and has 'tech2' as pending. */
INSERT INTO emp.technologies_v2 ( empire_id , technology_name_id , emptech_state , emptech_points , emptech_priority ) INSERT INTO emp.technologies ( empire_id , technology_name_id , emptech_state , emptech_points , emptech_priority )
VALUES( _get_emp_name( 'emp3' ) , _get_string( 'tech1' ) , 'KNOWN' , NULL , NULL ) , VALUES( _get_emp_name( 'emp3' ) , _get_string( 'tech1' ) , 'KNOWN' , NULL , NULL ) ,
( _get_emp_name( 'emp3' ) , _get_string( 'tech2' ) , 'PENDING' , NULL , NULL ); ( _get_emp_name( 'emp3' ) , _get_string( 'tech2' ) , 'PENDING' , NULL , NULL );
/* Empire "emp4" has implemented 'tech1' and 'tech2' and has 'tech3' as pending. */ /* Empire "emp4" has implemented 'tech1' and 'tech2' and has 'tech3' as pending. */
INSERT INTO emp.technologies_v2 ( empire_id , technology_name_id , emptech_state , emptech_points , emptech_priority ) INSERT INTO emp.technologies ( empire_id , technology_name_id , emptech_state , emptech_points , emptech_priority )
VALUES( _get_emp_name( 'emp4' ) , _get_string( 'tech1' ) , 'KNOWN' , NULL , NULL ) , VALUES( _get_emp_name( 'emp4' ) , _get_string( 'tech1' ) , 'KNOWN' , NULL , NULL ) ,
( _get_emp_name( 'emp4' ) , _get_string( 'tech2' ) , 'KNOWN' , NULL , NULL ) , ( _get_emp_name( 'emp4' ) , _get_string( 'tech2' ) , 'KNOWN' , NULL , NULL ) ,
( _get_emp_name( 'emp4' ) , _get_string( 'tech3' ) , 'PENDING' , NULL , NULL ); ( _get_emp_name( 'emp4' ) , _get_string( 'tech3' ) , 'PENDING' , NULL , NULL );
@ -72,7 +72,7 @@ BEGIN;
SELECT diag_test_name( 'emp.technology_implement() - Call on pending technology - No new research - Table contents' ); SELECT diag_test_name( 'emp.technology_implement() - Call on pending technology - No new research - Table contents' );
SELECT set_eq( $$ SELECT set_eq( $$
SELECT technology_name_id , emptech_state::TEXT SELECT technology_name_id , emptech_state::TEXT
FROM emp.technologies_v2 FROM emp.technologies
WHERE empire_id = _get_emp_name( 'emp2' ) WHERE empire_id = _get_emp_name( 'emp2' )
$$ , $$ VALUES( $$ , $$ VALUES(
_get_string( 'tech1' ) , 'KNOWN' _get_string( 'tech1' ) , 'KNOWN'
@ -88,7 +88,7 @@ BEGIN;
SELECT diag_test_name( 'emp.technology_implement() - Call on pending technology - New research - Table contents' ); SELECT diag_test_name( 'emp.technology_implement() - Call on pending technology - New research - Table contents' );
SELECT set_eq( $$ SELECT set_eq( $$
SELECT technology_name_id , emptech_state::TEXT SELECT technology_name_id , emptech_state::TEXT
FROM emp.technologies_v2 FROM emp.technologies
WHERE empire_id = _get_emp_name( 'emp3' ) WHERE empire_id = _get_emp_name( 'emp3' )
$$ , $$ VALUES( $$ , $$ VALUES(
_get_string( 'tech1' ) , 'KNOWN' _get_string( 'tech1' ) , 'KNOWN'

View file

@ -46,7 +46,7 @@ BEGIN;
AS SELECT * FROM _fake_visibility; AS SELECT * FROM _fake_visibility;
/* Insert empire state and data for fake views */ /* Insert empire state and data for fake views */
INSERT INTO emp.technologies_v2 ( INSERT INTO emp.technologies (
empire_id , technology_name_id , empire_id , technology_name_id ,
emptech_state , emptech_points , emptech_priority emptech_state , emptech_points , emptech_priority
) VALUES ( ) VALUES (

View file

@ -23,7 +23,7 @@ BEGIN;
INSERT INTO defs.technologies ( technology_name_id ) INSERT INTO defs.technologies ( technology_name_id )
VALUES ( _get_string( 'tech1' ) ); VALUES ( _get_string( 'tech1' ) );
INSERT INTO emp.technologies_v2( INSERT INTO emp.technologies(
empire_id , technology_name_id , empire_id , technology_name_id ,
emptech_state , emptech_points , emptech_priority emptech_state , emptech_points , emptech_priority
) VALUES ( ) VALUES (
@ -52,7 +52,7 @@ BEGIN;
SELECT diag_test_name( 'emp.resprio_update_apply() - Applying a valid update - Table contents' ); SELECT diag_test_name( 'emp.resprio_update_apply() - Applying a valid update - Table contents' );
SELECT set_eq( $$ SELECT set_eq( $$
SELECT empire_id , emptech_priority SELECT empire_id , emptech_priority
FROM emp.technologies_v2 FROM emp.technologies
WHERE technology_name_id = _get_string( 'tech1' ); WHERE technology_name_id = _get_string( 'tech1' );
$$ , $$ VALUES( $$ , $$ VALUES(
_get_emp_name( 'emp1' ) , 1 _get_emp_name( 'emp1' ) , 1
@ -60,7 +60,7 @@ BEGIN;
_get_emp_name( 'emp2' ) , 2 _get_emp_name( 'emp2' ) , 2
) $$ ); ) $$ );
DELETE FROM rprio_update; DELETE FROM rprio_update;
UPDATE emp.technologies_v2 UPDATE emp.technologies
SET emptech_priority = 2 SET emptech_priority = 2
WHERE technology_name_id = _get_string( 'tech1' ); WHERE technology_name_id = _get_string( 'tech1' );
@ -71,7 +71,7 @@ BEGIN;
SELECT diag_test_name( 'emp.resprio_update_apply() - Applying an invalid update - Table contents' ); SELECT diag_test_name( 'emp.resprio_update_apply() - Applying an invalid update - Table contents' );
SELECT set_eq( $$ SELECT set_eq( $$
SELECT empire_id , emptech_priority SELECT empire_id , emptech_priority
FROM emp.technologies_v2 FROM emp.technologies
$$ , $$ VALUES( $$ , $$ VALUES(
_get_emp_name( 'emp1' ) , 2 _get_emp_name( 'emp1' ) , 2
) , ( ) , (

View file

@ -39,7 +39,7 @@ BEGIN;
( _get_string( 'tech6' ) , 1000 ); ( _get_string( 'tech6' ) , 1000 );
/* Insert empire state */ /* Insert empire state */
INSERT INTO emp.technologies_v2 ( INSERT INTO emp.technologies (
empire_id , technology_name_id , empire_id , technology_name_id ,
emptech_state , emptech_points , emptech_priority emptech_state , emptech_points , emptech_priority
) VALUES ( ) VALUES (

View file

@ -3,13 +3,13 @@
*/ */
BEGIN; BEGIN;
/* Remove foreign keys from the empire research table */ /* Remove foreign keys from the empire research table */
ALTER TABLE emp.technologies_v2 ALTER TABLE emp.technologies
DROP CONSTRAINT fk_emptech_empire , DROP CONSTRAINT fk_emptech_empire ,
DROP CONSTRAINT fk_emptech_technology; DROP CONSTRAINT fk_emptech_technology;
/* Insert a few records */ /* Insert a few records */
DELETE FROM emp.technologies_v2; DELETE FROM emp.technologies;
INSERT INTO emp.technologies_v2 ( INSERT INTO emp.technologies (
empire_id , technology_name_id , empire_id , technology_name_id ,
emptech_state , emptech_points , emptech_priority emptech_state , emptech_points , emptech_priority
) VALUES ) VALUES

View file

@ -1,5 +1,5 @@
/* /*
* Unit tests for emp.technologies_v2_view * Unit tests for emp.technologies_view
*/ */
BEGIN; BEGIN;
\i utils/strings.sql \i utils/strings.sql
@ -54,7 +54,7 @@ BEGIN;
AS SELECT * FROM _fake_deps; AS SELECT * FROM _fake_deps;
/* Insert empire states and data for fake views */ /* Insert empire states and data for fake views */
INSERT INTO emp.technologies_v2 ( INSERT INTO emp.technologies (
empire_id , technology_name_id , empire_id , technology_name_id ,
emptech_state , emptech_points , emptech_priority emptech_state , emptech_points , emptech_priority
) VALUES ( ) VALUES (
@ -79,14 +79,14 @@ BEGIN;
-- ***** TESTS BEGIN HERE ***** -- ***** TESTS BEGIN HERE *****
SELECT plan( 3 ); SELECT plan( 3 );
SELECT diag_test_name( 'emp.technologies_v2_view - Known technology' ); SELECT diag_test_name( 'emp.technologies_view - Known technology' );
SELECT set_eq( $$ SELECT set_eq( $$
SELECT emptech_id , emptech_state::TEXT , emptech_visible , SELECT emptech_id , emptech_state::TEXT , emptech_visible ,
technology_category , technology_name , technology_description , technology_category , technology_name , technology_description ,
emptech_points , emptech_priority IS NULL AS ep_null , emptech_points , emptech_priority IS NULL AS ep_null ,
emptech_ratio IS NULL AS er_null , emptech_ratio IS NULL AS er_null ,
technology_price , technology_dependencies technology_price , technology_dependencies
FROM emp.technologies_v2_view FROM emp.technologies_view
WHERE empire_id = _get_emp_name( 'emp1' ) WHERE empire_id = _get_emp_name( 'emp1' )
$$ , $$ VALUES( $$ , $$ VALUES(
_get_emp_name( 'emp1' ) || ',tech1,true' , 'KNOWN' , TRUE , _get_emp_name( 'emp1' ) || ',tech1,true' , 'KNOWN' , TRUE ,
@ -94,13 +94,13 @@ BEGIN;
456 , TRUE , TRUE , 123 , 'deps are here' 456 , TRUE , TRUE , 123 , 'deps are here'
) $$ ); ) $$ );
SELECT diag_test_name( 'emp.technologies_v2_view - In-progress, visible technology' ); SELECT diag_test_name( 'emp.technologies_view - In-progress, visible technology' );
SELECT set_eq( $$ SELECT set_eq( $$
SELECT emptech_id , emptech_state::TEXT , emptech_visible , SELECT emptech_id , emptech_state::TEXT , emptech_visible ,
technology_category , technology_name , technology_description , technology_category , technology_name , technology_description ,
emptech_points , emptech_priority , emptech_ratio , emptech_points , emptech_priority , emptech_ratio ,
technology_price , technology_dependencies technology_price , technology_dependencies
FROM emp.technologies_v2_view FROM emp.technologies_view
WHERE empire_id = _get_emp_name( 'emp2' ) WHERE empire_id = _get_emp_name( 'emp2' )
$$ , $$ VALUES( $$ , $$ VALUES(
_get_emp_name( 'emp2' ) || ',tech1,true' , 'RESEARCH' , TRUE , _get_emp_name( 'emp2' ) || ',tech1,true' , 'RESEARCH' , TRUE ,
@ -108,13 +108,13 @@ BEGIN;
228 , 0 , 50 , 123 , 'deps are here' 228 , 0 , 50 , 123 , 'deps are here'
) $$ ); ) $$ );
SELECT diag_test_name( 'emp.technologies_v2_view - In-progress, unknown technology' ); SELECT diag_test_name( 'emp.technologies_view - In-progress, unknown technology' );
SELECT set_eq( $$ SELECT set_eq( $$
SELECT emptech_id , emptech_state::TEXT , emptech_visible , SELECT emptech_id , emptech_state::TEXT , emptech_visible ,
technology_category , technology_name IS NULL AS n1 , technology_description IS NULL AS n2 , technology_category , technology_name IS NULL AS n1 , technology_description IS NULL AS n2 ,
emptech_points IS NULL AS n3 , emptech_priority , emptech_ratio , emptech_points IS NULL AS n3 , emptech_priority , emptech_ratio ,
technology_price IS NULL AS n4, technology_dependencies technology_price IS NULL AS n4, technology_dependencies
FROM emp.technologies_v2_view FROM emp.technologies_view
WHERE empire_id = _get_emp_name( 'emp3' ) WHERE empire_id = _get_emp_name( 'emp3' )
$$ , $$ VALUES( $$ , $$ VALUES(
_get_emp_name( 'emp3' ) || ',tech1,false' , 'RESEARCH' , FALSE , _get_emp_name( 'emp3' ) || ',tech1,false' , 'RESEARCH' , FALSE ,

View file

@ -5,10 +5,10 @@ BEGIN;
SELECT plan( 1 ); SELECT plan( 1 );
SELECT diag_test_name( 'emp.technology_make_identifier() - No EXECUTE privilege' ); SELECT diag_test_name( 'emp.technology_make_identifier() - EXECUTE privilege' );
SELECT throws_ok( $$ SELECT lives_ok( $$
SELECT emp.technology_make_identifier( 1 , '' , FALSE ); SELECT emp.technology_make_identifier( 1 , '' , FALSE );
$$ , 42501 ); $$ );
SELECT * FROM finish( ); SELECT * FROM finish( );
ROLLBACK; ROLLBACK;

View file

@ -1,14 +1,14 @@
/* /*
* Test privileges on emp.technologies_v2_view * Test privileges on emp.technologies_view
*/ */
BEGIN; BEGIN;
\i utils/strings.sql \i utils/strings.sql
SELECT plan( 1 ); SELECT plan( 1 );
SELECT diag_test_name( 'emp.technologies_v2_view - SELECT privilege' ); SELECT diag_test_name( 'emp.technologies_view - SELECT privilege' );
SELECT lives_ok( $$ SELECT lives_ok( $$
SELECT * FROM emp.technologies_v2_view; SELECT * FROM emp.technologies_view;
$$ ); $$ );
SELECT * FROM finish( ); SELECT * FROM finish( );

View file

@ -47,7 +47,7 @@ INSERT INTO verse.planet_happiness( planet_id , target , current )
*/ */
INSERT INTO emp.empires( name_id , cash ) INSERT INTO emp.empires( name_id , cash )
VALUES( _get_emp_name( 'emp1' ) , 100.0 ); VALUES( _get_emp_name( 'emp1' ) , 100.0 );
INSERT INTO emp.technologies_v2 ( INSERT INTO emp.technologies (
empire_id , technology_name_id , empire_id , technology_name_id ,
emptech_state , emptech_points , emptech_priority ) emptech_state , emptech_points , emptech_priority )
SELECT _get_emp_name( 'emp1' ) , technology_name_id , 'KNOWN' , NULL , NULL SELECT _get_emp_name( 'emp1' ) , technology_name_id , 'KNOWN' , NULL , NULL
@ -59,7 +59,7 @@ INSERT INTO emp.technologies_v2 (
*/ */
INSERT INTO emp.empires( name_id , cash ) INSERT INTO emp.empires( name_id , cash )
VALUES( _get_emp_name( 'emp2' ) , 100.0 ); VALUES( _get_emp_name( 'emp2' ) , 100.0 );
INSERT INTO emp.technologies_v2 ( INSERT INTO emp.technologies (
empire_id , technology_name_id , empire_id , technology_name_id ,
emptech_state , emptech_points , emptech_priority ) emptech_state , emptech_points , emptech_priority )
SELECT _get_emp_name( 'emp2' ) , technology_name_id , 'KNOWN' , NULL , NULL SELECT _get_emp_name( 'emp2' ) , technology_name_id , 'KNOWN' , NULL , NULL
@ -72,7 +72,7 @@ INSERT INTO emp.planets( empire_id , planet_id )
*/ */
INSERT INTO emp.empires( name_id , cash ) INSERT INTO emp.empires( name_id , cash )
VALUES( _get_emp_name( 'emp3' ) , 100.0 ); VALUES( _get_emp_name( 'emp3' ) , 100.0 );
INSERT INTO emp.technologies_v2 ( empire_id , technology_name_id ) INSERT INTO emp.technologies ( empire_id , technology_name_id )
SELECT _get_emp_name( 'emp3' ) , technology_name_id SELECT _get_emp_name( 'emp3' ) , technology_name_id
FROM defs.technologies; FROM defs.technologies;
@ -82,7 +82,7 @@ INSERT INTO emp.technologies_v2 ( empire_id , technology_name_id )
*/ */
INSERT INTO emp.empires( name_id , cash ) INSERT INTO emp.empires( name_id , cash )
VALUES( _get_emp_name( 'emp4' ) , 100.0 ); VALUES( _get_emp_name( 'emp4' ) , 100.0 );
INSERT INTO emp.technologies_v2 ( empire_id , technology_name_id ) INSERT INTO emp.technologies ( empire_id , technology_name_id )
SELECT _get_emp_name( 'emp4' ) , technology_name_id SELECT _get_emp_name( 'emp4' ) , technology_name_id
FROM defs.technologies; FROM defs.technologies;
INSERT INTO emp.planets( empire_id , planet_id ) INSERT INTO emp.planets( empire_id , planet_id )
@ -97,7 +97,7 @@ INSERT INTO emp.planets( empire_id , planet_id )
*/ */
INSERT INTO emp.empires( name_id , cash ) INSERT INTO emp.empires( name_id , cash )
VALUES( _get_emp_name( 'emp5' ) , 100.0 ); VALUES( _get_emp_name( 'emp5' ) , 100.0 );
INSERT INTO emp.technologies_v2 ( empire_id , technology_name_id ) INSERT INTO emp.technologies ( empire_id , technology_name_id )
SELECT _get_emp_name( 'emp5' ) , technology_name_id SELECT _get_emp_name( 'emp5' ) , technology_name_id
FROM defs.technologies; FROM defs.technologies;
INSERT INTO emp.planets( empire_id , planet_id ) INSERT INTO emp.planets( empire_id , planet_id )
@ -117,7 +117,7 @@ INSERT INTO users.vacations ( account_id , since , status )
*/ */
INSERT INTO emp.empires( name_id , cash ) INSERT INTO emp.empires( name_id , cash )
VALUES( _get_emp_name( 'emp6' ) , 100.0 ); VALUES( _get_emp_name( 'emp6' ) , 100.0 );
INSERT INTO emp.technologies_v2 ( empire_id , technology_name_id ) INSERT INTO emp.technologies ( empire_id , technology_name_id )
SELECT _get_emp_name( 'emp6' ) , technology_name_id SELECT _get_emp_name( 'emp6' ) , technology_name_id
FROM defs.technologies; FROM defs.technologies;
INSERT INTO emp.planets( empire_id , planet_id ) INSERT INTO emp.planets( empire_id , planet_id )