← Back to team overview

phpdevshell team mailing list archive

[Bug 924728] [NEW] PHPDS_query keyField=__auto__ causes primary key headaches

 

Public bug reported:

By default a query is assumed to make the array key the id of the
primary key field. This caused problems with other developers before as
it assumes that the primary field will be unique and auto-incremented. I
think the logic behind this is very limited and will in the future cause
other potential bugs. The current bug I am battling is this:

Assuming we dont have an id field and only have to key field, something
like this:

CREATE TABLE `pds_core_user_role_permissions` (
  `user_role_id` int(10) NOT NULL DEFAULT '0',
  `menu_id` varchar(32) NOT NULL,
  PRIMARY KEY (`user_role_id`,`menu_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Assuming we add values like these,

INSERT INTO pds_core_user_role_permissions VALUES ('1', '1016054546');
INSERT INTO pds_core_user_role_permissions VALUES ('1', '1210756465');
INSERT INTO pds_core_user_role_permissions VALUES ('1', '131201277');
INSERT INTO pds_core_user_role_permissions VALUES ('1', '1363712008');
INSERT INTO pds_core_user_role_permissions VALUES ('1', '1405303115');
INSERT INTO pds_core_user_role_permissions VALUES ('1', '1411278578');
INSERT INTO pds_core_user_role_permissions VALUES ('1', '1440418834');

Now the system will only return a single row when queried as __auto__
assumed incorrectly. It basicly assigned 1 as the key array field hence
overriding it every time.

** Affects: phpdevshell
     Importance: High
     Assignee: TitanKing (titan-phpdevshell)
         Status: In Progress

** Description changed:

  By default a query is assumed to make the array key the id of the
  primary key field. This caused problems with other developers before as
  it assumes that the primary field will be unique and auto-incremented. I
  think the logic behind this is very limited and will in the future cause
  other potential bugs. The current bug I am battling is this:
  
  Assuming we dont have an id field and only have to key field, something
  like this:
  
  CREATE TABLE `pds_core_user_role_permissions` (
-   `user_role_id` int(10) NOT NULL DEFAULT '0',
-   `menu_id` varchar(32) NOT NULL,
-   PRIMARY KEY (`user_role_id`,`menu_id`)
+   `user_role_id` int(10) NOT NULL DEFAULT '0',
+   `menu_id` varchar(32) NOT NULL,
+   PRIMARY KEY (`user_role_id`,`menu_id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  
  Assuming we add values like these,
  
  INSERT INTO pds_core_user_role_permissions VALUES ('1', '1016054546');
  INSERT INTO pds_core_user_role_permissions VALUES ('1', '1210756465');
  INSERT INTO pds_core_user_role_permissions VALUES ('1', '131201277');
  INSERT INTO pds_core_user_role_permissions VALUES ('1', '1363712008');
  INSERT INTO pds_core_user_role_permissions VALUES ('1', '1405303115');
  INSERT INTO pds_core_user_role_permissions VALUES ('1', '1411278578');
  INSERT INTO pds_core_user_role_permissions VALUES ('1', '1440418834');
  
  Now the system will only return a single row as __auto__ assumed
- incorrectly.
+ incorrectly. It basicly assigned 1 as the key array field hence
+ overriding it every time.

** Changed in: phpdevshell
       Status: New => In Progress

** Changed in: phpdevshell
   Importance: Undecided => High

** Changed in: phpdevshell
     Assignee: (unassigned) => TitanKing (titan-phpdevshell)

** Changed in: phpdevshell
    Milestone: None => 3.1.3-stable

** Description changed:

  By default a query is assumed to make the array key the id of the
  primary key field. This caused problems with other developers before as
  it assumes that the primary field will be unique and auto-incremented. I
  think the logic behind this is very limited and will in the future cause
  other potential bugs. The current bug I am battling is this:
  
  Assuming we dont have an id field and only have to key field, something
  like this:
  
  CREATE TABLE `pds_core_user_role_permissions` (
    `user_role_id` int(10) NOT NULL DEFAULT '0',
    `menu_id` varchar(32) NOT NULL,
    PRIMARY KEY (`user_role_id`,`menu_id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  
  Assuming we add values like these,
  
  INSERT INTO pds_core_user_role_permissions VALUES ('1', '1016054546');
  INSERT INTO pds_core_user_role_permissions VALUES ('1', '1210756465');
  INSERT INTO pds_core_user_role_permissions VALUES ('1', '131201277');
  INSERT INTO pds_core_user_role_permissions VALUES ('1', '1363712008');
  INSERT INTO pds_core_user_role_permissions VALUES ('1', '1405303115');
  INSERT INTO pds_core_user_role_permissions VALUES ('1', '1411278578');
  INSERT INTO pds_core_user_role_permissions VALUES ('1', '1440418834');
  
- Now the system will only return a single row as __auto__ assumed
- incorrectly. It basicly assigned 1 as the key array field hence
+ Now the system will only return a single row when queried as __auto__
+ assumed incorrectly. It basicly assigned 1 as the key array field hence
  overriding it every time.

-- 
You received this bug notification because you are a member of
PHPDevShell, which is subscribed to PHPDevShell.
https://bugs.launchpad.net/bugs/924728

Title:
  PHPDS_query keyField=__auto__ causes primary key headaches

Status in Open Source PHP RAD Framework with UI.:
  In Progress

Bug description:
  By default a query is assumed to make the array key the id of the
  primary key field. This caused problems with other developers before
  as it assumes that the primary field will be unique and auto-
  incremented. I think the logic behind this is very limited and will in
  the future cause other potential bugs. The current bug I am battling
  is this:

  Assuming we dont have an id field and only have to key field,
  something like this:

  CREATE TABLE `pds_core_user_role_permissions` (
    `user_role_id` int(10) NOT NULL DEFAULT '0',
    `menu_id` varchar(32) NOT NULL,
    PRIMARY KEY (`user_role_id`,`menu_id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

  Assuming we add values like these,

  INSERT INTO pds_core_user_role_permissions VALUES ('1', '1016054546');
  INSERT INTO pds_core_user_role_permissions VALUES ('1', '1210756465');
  INSERT INTO pds_core_user_role_permissions VALUES ('1', '131201277');
  INSERT INTO pds_core_user_role_permissions VALUES ('1', '1363712008');
  INSERT INTO pds_core_user_role_permissions VALUES ('1', '1405303115');
  INSERT INTO pds_core_user_role_permissions VALUES ('1', '1411278578');
  INSERT INTO pds_core_user_role_permissions VALUES ('1', '1440418834');

  Now the system will only return a single row when queried as __auto__
  assumed incorrectly. It basicly assigned 1 as the key array field
  hence overriding it every time.

To manage notifications about this bug go to:
https://bugs.launchpad.net/phpdevshell/+bug/924728/+subscriptions


Follow ups

References