Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL Error - Unknown column 'LinkType' in 'where clause' #101

Open
extravio opened this issue Mar 13, 2019 · 2 comments
Open

SQL Error - Unknown column 'LinkType' in 'where clause' #101

extravio opened this issue Mar 13, 2019 · 2 comments

Comments

@extravio
Copy link

extravio commented Mar 13, 2019

In the CMS, the "link existing" ajax call triggers the following error:

ERROR [Emergency]: Uncaught SilverStripe\ORM\Connect\DatabaseException: Couldn't run query:

SELECT DISTINCT "LinkableLink"."ClassName", "LinkableLink"."LastEdited", "LinkableLink"."Created", "LinkableLink"."Anchor", "LinkableLink"."Title", "LinkableLink"."Type", "LinkableLink"."URL", "LinkableLink"."Email", "LinkableLink"."Phone", "LinkableLink"."OpenInNewWindow", "LinkableLink"."Template", "LinkableLink"."SiteTreeID", "LinkableLink"."FileID", "LinkableLink"."ID", 
			CASE WHEN "LinkableLink"."ClassName" IS NOT NULL THEN "LinkableLink"."ClassName"
			ELSE 'Sheadawson\\Linkable\\Models\\Link' END AS "RecordClassName"

FROM "LinkableLink"

WHERE ("LinkableLink"."ID" NOT IN 
SELECT DISTINCT "LinkableLink"."ID"

FROM "LinkableLink"
INNER JOIN "ContactUsPage_LinkedPages" ON "ContactUsPage_LinkedPages"."LinkableLinkID" = "LinkableLink"."ID"

WHERE ("ContactUsPage_LinkedPages"."ContactUsPageID" = ?)))
 AND (("LinkableLink"."Title" LIKE ?)
 OR ("LinkType" LIKE ?)
 OR ("LinkURL" LIKE ?))

ORDER BY "LinkableLink"."Title" ASC

LIMIT 20

Unknown column 'LinkType' in 'where clause'
IN GET /admin/pages/edit/EditForm/7/field/LinkedPages/search?gridfield_relationsearch=test
Line 64 in /var/www/html/vendor/silverstripe/framework/src/ORM/Connect/DBConnector.php

Source
======
  55:          if (!empty($sql)) {
  56:              $formatter = new SQLFormatter();
  57:              $formattedSQL = $formatter->formatPlain($sql);
  58:              $msg = "Couldn't run query:\n\n{$formattedSQL}\n\n{$msg}";
  59:          }
  60:  
  61:          if ($errorLevel === E_USER_ERROR) {
  62:              // Treating errors as exceptions better allows for responding to errors
  63:              // in code, such as credential checking during installation
* 64:              throw new DatabaseException($msg, 0, null, $sql, $parameters);
  65:          } else {
  66:              user_error($msg, $errorLevel);
  67:          }
  68:      }
  69:  
  70:      /**

linkable_error

@normann
Copy link

normann commented Nov 1, 2019

This issue seemed very often being caught, i.e. when searching a Link object in either a ModelAdmin which manages Links or a GridFiled's "link existing" lookup.
Could any maintainer of the module have a look at this issue, please?

@sunnysideup
Copy link
Contributor

sunnysideup commented Nov 19, 2020

see: #109.

If you are looking for a fix now, add this to app/_config/link.yml:

---
Name: app-link
---

Sheadawson\Linkable\Models\Link:
  searchable_fields:
    Title: PartialMatchFilter
    URL: PartialMatchFilter
    Phone: PartialMatchFilter
    Email: PartialMatchFilter

sheadawson added a commit that referenced this issue Nov 19, 2020
fix common issue in ModelAdmin search  (#101)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants