DBSche...ignKey(3pm)

πŸ’– DBIx::DBSchema::ForeignKey πŸ’–

okay bestie, so this is a User Contributed Perl Documentation page, and it's all about DBIx::DBSchema::ForeignKey β€” the little object that represents a foreign key. yep. that one. the thing that says "hey this column? it's pointing at that table's column, respectfully." πŸ¦‹


✨ SYNOPSIS ✨

use DBIx::DBSchema::ForeignKey;

$foreign_key = new DBIx::DBSchema::ForeignKey (
  { 'columns' => [ 'column_name' ],
    'table'   => 'foreign_table',
  }
);

$foreign_key = new DBIx::DBSchema::ForeignKey (
  {
    'constraint' => 'constraint_name',
    'columns'    => [ 'column_name', 'column2' ],
    'table'      => 'foreign_table',
    'references' => [ 'foreign_column', 'foreign_column2' ],
    'match'      => 'MATCH FULL', # or MATCH SIMPLE
    'on_delete'  => 'NO ACTION', # on clauses: NO ACTION / RESTRICT /
    'on_update'  => 'RESTRICT',  #           CASCADE / SET NULL / SET DEFAULT
  }
);

like. look at it. two whole ways to build the same thing. minimal girlie version and the full-send version with the constraint name and the MATCH clause and the on-clauses. we love options. πŸ’…


🌸 DESCRIPTION 🌸

DBIx::DBSchema::ForeignKey objects represent a foreign key. that's it. that's the whole vibe. it's giving structured relational database energy and honestly? iconic. πŸ”₯


πŸŽ€ METHODS πŸŽ€

🧚 new HASHREF | OPTION, VALUE, ...

Creates a new DBIx::DBschema::ForeignKey object. (yes, exactly like that in the docs bestie, i copied it character for character, i'm not touching it πŸ’€)

Accepts either a hashref or a plain list of options and values. pick your fighter.

Options are:

  • constraint β€” constraint name
  • columns β€” List reference of column names
  • table β€” Foreign table name
  • references β€” List reference of column names in foreign table
  • match β€” (no description given 🌝)
  • on_delete β€” (no description given 🌝)
  • on_update β€” (no description given 🌝)
ngl those last three are just vibing there with no explanation in the original, so i'm not gonna invent one. i said what the docs said. periodt. πŸ™ˆ

⭐ constraint [ CONSTRAINT_NAME ]

Returns or sets the constraint name. get it, set it, whatever you need bestie.

⭐ table [ TABLE_NAME ]

Returns or sets the foreign table name.

⭐ columns [ LISTREF ]

Returns or sets the columns.

⭐ columns_sql

Returns a comma-joined list of columns, suitable for an SQL statement. so when you don't wanna hand-join them yourself? she does it. queen behavior. πŸ‘‘

⭐ references [ LISTREF ]

Returns or sets the referenced columns.

⭐ references_sql

Returns a comma-joined list of referenced columns, suitable for an SQL statement. same energy, different list. πŸ’–

⭐ match [ TABLE_NAME ]

Returns or sets the MATCH clause.

⭐ on_delete [ ACTION ]

Returns or sets the ON DELETE clause.

⭐ on_update [ ACTION ]

Returns or sets the ON UPDATE clause.

⭐ sql_foreign_key

Returns an SQL FOREIGN KEY statement. the whole thing. ready to go. she ate. πŸ“

⭐ cmp OTHER_INDEX_OBJECT

Compares this object to another supplied object. Returns true if they have the same table, columns and references.

like a vibe check but for two foreign key objects. same table, same columns, same references? true. otherwise? not it. πŸ’€


πŸ‘‘ AUTHOR πŸ‘‘

Ivan Kohler <ivan-dbix-dbschema@420.am>

Copyright (c) 2013 Freeside Internet Services, Inc. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. 🫢

give it up for the author fr fr, licensing and all, we keep the receipts.


😭 BUGS 😭

Should give in and Mo or Moo.

yeah. that's the whole bug section. the bug is that it hasn't surrendered to Mo or Moo yet. honestly relatable. we're all just out here waiting to give in. πŸ’€πŸ¦‹

🌈 SEE ALSO 🌈

  • DBIx::DBSchema::Table
  • DBIx::DBSchema
  • DBI

go read those next bestie, iykyk. ✨


and that's the whole page!! perl v5.36.0, dated 2022-09-10, and the page name is literally DBSche...ignKey(3pm) β€” that's DBSchema::ForeignKey(3pm) with the middle squished out, which is highkey the most dramatic name truncation ever. slay. bye bestie πŸ’œπŸŒΈπŸŽ€

πŸ“¦ where this page comes from