API page: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Database%...

On all api pages for Drupal where addField() is a known function, the description tells you:

Alternatively, the 'initial_form_field' key may be used, which will auto-populate the new field with values from the specified field.

But this doesn't work, and that's because of a simple typo. In the php code itself the spec checks on: if (isset($spec['initial_from_field'])) {

It's a small typo, but when you don't look at the code, but just the description, it will not work:

initial_from_field
initial_form_field

Please update the description to match the code, so people won't think this doesn't work:

$spec: The field specification array, as taken from a schema definition. The specification may also contain the key 'initial', the newly created field will be set to the value of the key in all rows. This is most useful for creating NOT NULL columns with no default value in existing tables. Alternatively, the 'initial_from_field' key may be used, which will auto-populate the new field with values from the specified field.

Issue fork drupal-3295972

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Krilo_89 created an issue. See original summary.

cilefen’s picture

Version: 9.0.x-dev » 9.4.x-dev
cilefen’s picture

Issue tags: +Novice
chaubeyji’s picture

Assigned: Unassigned » chaubeyji
chaubeyji’s picture

Assigned: chaubeyji » Unassigned
arunkumark’s picture

Version: 9.4.x-dev » 9.5.x-dev
Component: documentation » sqlite db driver
Issue tags: +typo
FileSize
8.17 KB

Actually, this is a typo mistake(initial_from_field can be replaced to initial_form_field), instead of updating the document we can correct the code level.

Created the patch to updating into the code level.

cilefen’s picture

Component: sqlite db driver » database system
Status: Active » Needs work

I disagree: initial_from_field is correct.

nitin_lama’s picture

Assigned: Unassigned » nitin_lama
nitin_lama’s picture

Assigned: nitin_lama » Unassigned
Status: Needs work » Needs review
FileSize
790 bytes

Adding patch to update the description.

Munavijayalakshmi’s picture

Assigned: Unassigned » Munavijayalakshmi
Munavijayalakshmi’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
83.97 KB
67.73 KB

Both patches applied successfully.
As per description comment #9 is correct.
As per code level Comment #6 is correct.

Marking this as RTBC.

Munavijayalakshmi’s picture

Assigned: Munavijayalakshmi » Unassigned

  • catch committed bd4f7e4 on 10.0.x
    Issue #3295972 by Munavijayalakshmi, nitin_lama, arunkumark, cilefen,...
  • catch committed a753e0e on 10.1.x
    Issue #3295972 by Munavijayalakshmi, nitin_lama, arunkumark, cilefen,...
  • catch committed c74043c on 9.4.x
    Issue #3295972 by Munavijayalakshmi, nitin_lama, arunkumark, cilefen,...
  • catch committed 8480dc6 on 9.5.x
    Issue #3295972 by Munavijayalakshmi, nitin_lama, arunkumark, cilefen,...
catch’s picture

Version: 9.5.x-dev » 9.4.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 10.1.x, cherry-picked to 10.0.x/9.5.x/9.4.x, thanks!

@Munavijayalakshmi there's no need to update screenshots to show the patch applying since DrupalCI tests us this directly on the issue. Additionally, there's no need to open an MR if there's a viable patch on the issue - we still use both patches and MRs. Having said this, retained review credit because other steps were taken too.

Krilo_89’s picture

Thanks @catch!

Didn't had the time to add the MR myself and it actually surprised me, how many people were so fast to add something in this ticket for credits only...

I'm just glad the docs are matching now.

Munavijayalakshmi’s picture

Thanks.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.