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

Can't preview email using postgres, no function Rand() #1673

Closed
fireynis opened this issue Aug 26, 2020 · 1 comment
Closed

Can't preview email using postgres, no function Rand() #1673

fireynis opened this issue Aug 26, 2020 · 1 comment
Assignees

Comments

@fireynis
Copy link

Description
In the control panel, selecting preview for an email template for orders will result in an error as PostgresSql does not have a Rand() function.

To Reproduce
How, and what happened?

  1. Go to emails
  2. Attempt to preview one on a site using postgres

Expected behavior
The preview would open and the email would be displayed using an order

Additional info

  • Craft version: Craft Pro 3.5.6
  • Commerce version: 3.2.3
  • PHP version: 7.3.17
  • Database driver & version: PostgreSQL 12.2

Additional context
The issue is in the preview set up, specifically in vendor/craftcms/commerce/src/controllers/EmailsController.php at line 49– craft\elements\db\ElementQuery::one() at line 49 $order = Order::find()->isCompleted(true)->orderBy('RAND()')->one();

That RAND() call will not work with a Postgres database, it has the order by function of random() instead.

@lukeholder
Copy link
Member

Thanks, this has been fixed for the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants