DRUPAL error PDOException: SQLSTATE[42S22]: - drupal

can someone help me to fix this
Additional uncaught exception thrown while handling exception.
Original
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'base.owner' in 'field list': SELECT base.id AS id, base.name AS name, base.label AS label, base.plugin AS plugin, base.active AS active, base.weight AS weight, base.status AS status, base.dirty AS dirty, base.module AS module, base.owner AS owner, base.access_exposed AS access_exposed, base.data AS data FROM {rules_config} base WHERE (base.plugin = :db_condition_placeholder_0) AND (base.active = :db_condition_placeholder_1) ; Array ( [:db_condition_placeholder_0] => reaction rule [:db_condition_placeholder_1] => 1 ) in EntityAPIController->query() (line 187 of /home/tjmcom/public_html/mydomain. com/sites/all/modules/entity/includes/entity.controller.inc).
Additional
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'base.owner' in 'field list': SELECT base.id AS id, base.name AS name, base.label AS label, base.plugin AS plugin, base.active AS active, base.weight AS weight, base.status AS status, base.dirty AS dirty, base.module AS module, base.owner AS owner, base.access_exposed AS access_exposed, base.data AS data FROM {rules_config} base WHERE (base.plugin = :db_condition_placeholder_0) AND (base.active = :db_condition_placeholder_1) ; Array ( [:db_condition_placeholder_0] => reaction rule [:db_condition_placeholder_1] => 1 ) in EntityAPIController->query() (line 187 of /home/tjmcom/public_html/mydomain. com/sites/all/modules/entity/includes/entity.controller.inc).

This sounds like a problem with the Rules Project not having completed its update. Put your site in maintenance mode and go to yoursite.com/update.php.
This issue is documented at https://www.drupal.org/project/rules/issues/2094879 and comment #45 gives a checklist of items to do. If that does not work, please confirm you're indeed using Rules in your setup, and what version you're running.
Furthermore, if you have unsuccessfully tried any specific steps to resolve this issue and it persists, describe briefly what they were. It'll save time to getting you on the right path, avoiding describing suggestions you already tried. (You'll find tips on how to receive quicker and better answers over at https://stackoverflow.com/questions/how-to-ask.)
Welcome to StackOver flow.

Related

Inserting data into SQLite database fails with sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type

I have looked through quite a lot of the ones raised on this site and unless I am being dense ( Which who knows), I don't think they quite replicate my issue.
First let me start with some Code snippets
table
CREATE TABLE IF NOT EXISTS moves(
ID INTEGER PRIMARY KEY AUTOINCREMENT,
name char(20),
type char(10),
category char(10),
desc char(200),
share char(3),
priority char(5),
damage_dice char(5),
cool_down char(8),
accuracy char(100),
effect char(200),
move_target char(50),
makes_contact char(3),
contest_cat char(10)
)''')
The insert function
def insert_moves(move):
c = dbConn.cursor()
statement = '''insert into moves values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)'''
try:
c.execute(statement,(move[0], str(move[1]), str(move[2]), str(move[3]), str(move[4]),
str(move[5]), str(move[6]), str(move[7]), str(move[8]), str(move[9]), str(move[10]),
str(move[11]), str(move[12]), str(move[13]),))
dbConn.commit()
return True, ''
except Exception as e:
return False, e
Now, let me show you the stack trace and as part of that, you will see the printed output of move before its passed into the datebase function.
Now, this is the output
[1, 'Attack Order', 'Bug', 'Physical', 'The user calls out its underlings to pummel the target.', 'Yes', '-', '1d6', '1 Turn', '100', 'Attack Order deals damage and has an increased critical hit ratio of 50 percent', 'Targets a single adjacent Pokemon.', 'No', 'Clever']
Ignoring exception in command update_moves:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/projects/pokebot/gsheet.py", line 59, in update_moves
result, error2 = db.insert_moves(moves)
File "/projects/pokebot/db.py", line 103, in insert_moves
c.execute(statement,(move[0], str(move[1]), str(move[2]), str(move[3]), str(move[4]), str(move[5]), str(move[6]), str(move[7]), str(move[8]), str(move[9]), str(move[10]), str(move[11]), str(move[12]), str(move[13]),))
sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/discord/ext/commands/bot.py", line 903, in invoke
await ctx.command.invoke(ctx)
File "/usr/local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 859, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/usr/local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: InterfaceError: Error binding parameter 0 - probably unsupported type.
I have tried a few things such as removing random percent signs in case that was the issue, or changing Pokémon to Pokemon. But I don't see what the issue is. A lot of the others were all about people sending in things like Lists or objects to insert instead of some string/int object and I don't believe that to be the issue here. Is there anything that stands out?
So...this was definitely my fault. And if I had posted the function that called the insert, I would have seen it. I guess its just a friday afternoon and my brain is tired.
print(move)
result, error2 = db.insert_moves(move)
this was written as
print(move)
result, error2 = db.insert_moves(moves)
Where moves is iterated over so that I can do some work on it. Honestly, this was my fault completely. Oh well, I think the lesson is....on the insert function, if you are getting this error, check the type of the value passed. Which honestly, I should have done by now..but I'll just chalk it up to Friday afternoon.

Build query with aggregate functions in HAVING clause

I am trying to figure out how to have aggregate functions in the having clause with CakePHP's query builder.
Background: the intent is to correct all rows in a table with compound primary-keys (page-ID and URL) such that each page-ID-group has only one default video. There are some groups with no, and some groups with more than one "default" row, which needs to be corrected. I've figured out all the steps – except for this detail.
This is the query that I'm trying to build.
SELECT
video_page_id, video_url
FROM page_video
WHERE
video_page_id IN (
SELECT video_page_id
FROM page_video
GROUP BY video_page_id
HAVING SUM(video_is_default) < 1
)
AND video_order = 0
;
And this is what I have built:
// sub-select: all groups that have too few defaults.
// Returns list of page-IDs.
$qb = $this->getQueryBuilder();
$group_selection = $qb
->select(array(
'video_page_id',
))
->from('page_video')
->group('video_page_id')
->having(array(
'1 >' => $qb->func()->sum('video_is_default'),
))
;
// sub-select: compound-primary-key identifiers of all rows where
// `video_is_default` has to be modified from `0` to `1`.
// Returns list of two columns.
$qb = $this->getQueryBuilder();
$modifiable_selection = $qb
->select(array(
'video_page_id',
'video_url',
))
->from('page_video')
->where(array(
'video_page_id IN' => $group_selection,
'video_order = 0',
))
;
But then I get this exception: Column not found: 1054 Unknown column '1' in 'having clause'
The crux is the HAVING clause. I basically don't know how to combine the aggregate function with the attribute-value properties of an array. Usually, in order to craft lower/greater-than clauses, you write it like this: array('col1 >' => $value). But here, I needed to flip the equation because the complex expression can't fit into an array key. And now the 1 gets interpreted as a column name.
Writing it as a concatenated string doesn't seem to help either.
array(
$qb->func()->sum('video_is_default') .' > 1',
)
Exception: PHP Recoverable fatal error: Object of class Cake\Database\Expression\FunctionExpression could not be converted to string
I know I could do …
SELECT (…), SUM(video_is_default) AS default_sum FROM (…) HAVING default_sum < 1 (…)
… but then the sub-select column count doesn't match anymore.
Exception: ERROR 1241 (21000): Operand should contain 1 column(s)
I feel silly for figuring out the solution so soon after asking the question.
The lt method acccepts complex values as the first parameter.
->having(function($exp, $qb) {
$default_sum = $qb->func()->sum('video_is_default');
return $exp->lt($default_sum, 1);
})

How to write/extend custom DQL Function for Cast(X $comparisonOperator Y) in Doctrine? (Goal: Show related Objects)

To show related Articles on a website, I need the Cast() function.
My Query looks like:
SELECT
*,
(CAST(a.uploader = ?1 AS UNSIGNED)
+ CAST(a.param2 = ?2 AS UNSIGNED)
...
) AS matches_count
FROM articles AS a
ORDER BY matches_count DESC
It counts the matches and sorts by the highest number of matches_counts.
The problem is, that there's no Cast() function built into doctrine.
After hours of trial and error I found an already available custom DQL Function:
https://github.com/beberlei/DoctrineExtensions/blob/master/src/Query/Mysql/Cast.php
I registered it inside my doctrine.yml.
But it doesn't work, because it expects Cast(X AS Y) and not Cast(Y $comparisonOperator X).
When I'am using this inside my repository, by example:
$this->createQueryBuilder('a, (CAST(author=25 AS UNSIGNED) AS matches_count)')
->getQuery()
->getResult()
;
I get this error, because it doesn't expect a comparison operator:
[Syntax Error] line 0, col 29: Error: Expected Doctrine\ORM\Query\Lexer::T_AS, got '='
Do you know how to maybe extend that class for and not Cast(Y $comparisonOperator X) instead of Cast(X AS Y)?
I didn't find any solution on the internet and tried it for hours.
Thank you in advance for taking the time to write an answer!
Update:
I changed line 37 in the above mentioned custom DQL class for Cast:
//old
//$this->fieldIdentifierExpression = $parser->SimpleArithmeticExpression();
//new
$this->fieldIdentifierExpression = $parser->ComparisonExpression();
and how to create the query:
$this->createQueryBuilder('a')
->select('a, (CAST(a.averageRating=:averageRating AS UNSIGNED) + CAST(a.author=:author AS UNSIGNED)) AS matches_count')
->setParameter('averageRating', $averageRating)
->setParameter('author', $author)
->orderBy('matches_count', 'DESC')
->getQuery()
->getResult();
and that seems to be it!
I hope its the right way of doing it, will help someone and that is the best way for this purpose.
To improve performance later, I plan to cache 10 ids of recommended articles for every single article page into its own table.
So it doesn't need to do the calculation on page load.
This table could get recreated every 24h via a cronjob.
ID | recommended_article_ids | article_id
1 | 10,24,76,88| 5
Feedback and tips are much appreciated!

Drupal error PDOException SQLState[22007] 'invalid datetime format' in MoneySuite PayPerView

On pay-per-view content nodes (with Drupal MoneySuite module) when I click 'override settings' to input an amount/ type for then node it crashes with this error, though I have tried many versions for the price (eg 1, or 1.00) and dates (eg 2, or 2 days). I have tried using full html, filtered html and plain text in the settings for the field. One answer on Stackexhange hints that this is a ut8 issue but I don't know what that means about how to solve it? Any tips?
The error is:
PDOException: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'full_html' for column 'protected_content_message_format' at row 1: INSERT INTO {ms_ppv_price} (vid, nid, price, expiration_string, allow_multiple, protected_content_message, protected_content_message_format, stock, out_of_stock_message) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8); Array ( [:db_insert_placeholder_0] => 96 [:db_insert_placeholder_1] => 96 [:db_insert_placeholder_2] => 3 [:db_insert_placeholder_3] => 3 days [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => This is a premium film- pay per view only. Get access [ms_ppv:price] to view for [ms_ppv:expirationLength] : [ms_ppv:addToCartLink] [ms_ppv:nodeTeaser] [:db_insert_placeholder_6] => full_html [:db_insert_placeholder_7] => 0 [:db_insert_placeholder_8] => ) in ms_ppv_insert_node_price() (line 774 of /home/cineafzh/public_html/sites/all/modules/moneysuite/ms_ppv/ms_ppv.module).
Looks like the MoneySuite module created the database table incorrectly.
Your error message explains exactly what's going wrong.
Column 'protected_content_message_format' is defined as a datetime column in your database. The value the module attempts to store in it is 'full_html', which is a string. It fails validation and throws an exception.
One workaround would be to edit your database and change the type of column for 'protected_content_message_format' to string, instead of datetime.
I can't guarantee that this won't introduce other undesirable behaviour without looking at the code, but it would definitely resolve this specific error.

Doctrine PHPCR-ODM Query Builder selecting document inside specific node

I have the following nodes:
/
/applications
/applications/1
/applications/1/pages [contains Page documents]
I want to select all Page documents inside the node /applications/1. I used the following to do that (which seems right), but it throws an error:
$qb = $this->dm->createQueryBuilder();
$qb->from()->document('Mango\CoreDomainBundle\Document\Page', 'page');
// I want to select the pages which are a child of /applications/1
$qb->where()->child('/applications/1', 'application');
$qb->getQuery()->execute();
When I execute this, it throws the following error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'n1.id' in 'field list'
This is the SQL query that is send back to the database:
SELECT
n0.id AS n0_id,
n0.path AS n0_path,
n0.parent AS n0_parent,
n0.local_name AS n0_local_name,
n0.namespace AS n0_namespace,
n0.workspace_name AS n0_workspace_name,
n0.identifier AS n0_identifier,
n0.type AS n0_type,
n0.props AS n0_props,
n0.depth AS n0_depth,
n0.sort_order AS n0_sort_order,
n1.id AS n1_id,
n1.path AS n1_path,
n1.parent AS n1_parent,
n1.local_name AS n1_local_name,
n1.namespace AS n1_namespace,
n1.workspace_name AS n1_workspace_name,
n1.identifier AS n1_identifier,
n1.type AS n1_type,
n1.props AS n1_props,
n1.depth AS n1_depth,
n1.sort_order AS n1_sort_order
FROM
phpcr_nodes n0
WHERE
n0.workspace_name = 'mango'
AND n0.type IN ('nt:unstructured' , 'rep:root')
AND (n1.parent = 'applications/1'
AND (EXTRACTVALUE(n0.props,
'count(//sv:property[#sv:name="phpcr:class"]/sv:value[text()="Mango\CoreDomainBundle\Document\Page"]) > 0')
OR EXTRACTVALUE(n0.props,
'count(//sv:property[#sv:name="phpcr:classparents"]/sv:value[text()="Mango\CoreDomainBundle\Document\Page"]) > 0')))
I hope somebody can help me out! Thanks!
Hmm, it looks like I was just dumb :P The alias used as the second argument of the child condition has to be the alias of the document you run the query builder on.
Wrong:
$qb = $this->dm->getRepository('Mango\CoreDomainBundle\Document\Page')
->createQueryBuilder('page');
$qb->where()->child('/applications/456', 'alias_1');
Good
$qb = $this->dm->getRepository('Mango\CoreDomainBundle\Document\Page')
->createQueryBuilder('page');
$qb->where()->child('/applications/456', 'page');
Also, in my case, I had to use descendant rather than child. See http://docs.doctrine-project.org/projects/doctrine-phpcr-odm/en/latest/reference/query-builder-reference.html#descendant
Topic can be closed :)

Resources