Code Monkey home page Code Monkey logo

diesel.rs-website's Introduction

diesel.rs

This site is built using pandoc. The content is available here: https://diesel.rs

Build locally

make page

Master branch is automatically deployed to Github Pages.

diesel.rs-website's People

Contributors

alexcameron89 avatar alphabitserial avatar carols10cents avatar cllns avatar dependabot[bot] avatar eijebong avatar ernest-rudnicki avatar ggrochow avatar heycorwin avatar hi-rustin avatar hobofan avatar issyl0 avatar jangid avatar johntitor avatar joshuaogle avatar killercup avatar klautcomputing avatar moyeah avatar notryanb avatar ondrejkolin avatar rkochenderfer avatar rubenmp avatar sanchithhegde avatar sgrif avatar stanislav-tkach avatar tyoc213 avatar vmalloc avatar weiznich avatar wulf avatar zeroslope avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

diesel.rs-website's Issues

Update the getting started guide to diesel 2.0

As preparation of the upcoming diesel 2.0 release we need to update the guides on our web page to reflect the corresponding changes.
For the "Getting Started" guide this involves the following points:

  1. Update any code snippet to the corresponding variant from the 2.0.x branch
  2. Update any link pointing to the corresponding example in our repository to point to the 2.0.x branch
  3. Update any documentation link to point to the corresponding 2.0.x documentation page
  4. Update the note about the minimal supported rust version to state that at least rust 1.54 is required
  5. Update the note about embed_migrations! to the new syntax used there
  6. Open a PR with all this changes targeting the diesel_2.0_update branch

Please use this issue as discussion platform to ask any question that is unclear about updating this guide.

Update the "All about updates" guide to diesel 2.0

As preparation of the upcoming diesel 2.0 release we need to update the guides on our web page to reflect the corresponding changes.
For the "All about updates" guide this involves the following points:

  1. Update any code snippet to the corresponding variant from the 2.0.x branch
  2. Update any link pointing to the corresponding example in our repository to point to the 2.0.x branch
  3. Update any documentation link to point to the corresponding 2.0.x documentation page
  4. Open a PR with all this changes targeting the diesel_2.0_update branch

Please use this issue as discussion platform to ask any question that is unclear about updating this guide.

Enable SSL

Chrome now shows the URL as not secure. This can be done with a click of a button. In github pages config

I found an error of document on the official guides page.

Problem Description

On official guides the page Using Custom SQL and How to Extend the Query DSL, I found an error of document. See the following:

impl<T> Paginated<T> {
    fn load_and_count_pages<U>(self, conn: &PgConnection) -> QueryResult<(Vec<U>, i64)
    where
        Self: LoadQuery<PgConnection, (U, i64)>,
    {
        let per_page = self.per_page;
        let results = self.load::<(U, i64)>(conn)?;
        let total = results.get(0).map(|(_, total) _total|).unwrap_or(0);
        let records = results.into_iter().map(|(record, _)| record).collect();
        let total_pages = (total as f64 / per_page as f64).ceil() as i64;
        Ok((records, total_pages))
    }
}

The seventh line of the sample code above should be:

 let total = results.get(0).map(|(_, total)| _total).unwrap_or(0);

Build with a more recent version of pandoc ( > 2.11 )

The version of pandoc being used by the CI to build the site, has a quite annoying accessibility issue surrounding code-blocks.

Every line in a codeblock has an <a> tags with aria-hidden="true" on it, linking to an id element which is accessible via tab navigation through the site, causing anyone using that style of navigation to have to press tab to navigate past a hidden element for each line of code in any given example. further reading on the issue

This an example of the offending HTML from the website produced by pandoc 2.9.2.1 in your CI image

This issue has been fixed by later versions of pandoc by including the tabindex="-1" attribute on these a tags. I believe the fix lands in pandoc 2.11. pandoc release notes for 2.11 The fix is updating the skylight engine, where the actual fix occurred in their version 0.10. skylighting 0.10 changelog

This is what pandoc 2.17.1.1 produced for me when building it locally. image

Https redirect

Hi, i just noticed that if I dont explicitly go to the https site I will stay on the http site that could be a security risk for some users.
Cheers Konrad

Update the "Schema in depth" guide to diesel 2.0

As preparation of the upcoming diesel 2.0 release we need to update the guides on our web page to reflect the corresponding changes.
For the ["Schema in depth"](https://diesel.rs/guides/schema-in-depth.html guide this involves the following points:

  1. Update any documentation link to point to the corresponding 2.0.x documentation page
  2. Verify that the code snippet are still compile with diesel 2.0
  3. Open a PR with all this changes targeting the diesel_2.0_update branch

Please use this issue as discussion platform to ask any question that is unclear about updating this guide.

Segmentation fault

docker alpine rust
/app/diesel_demo # cargo -V
cargo 1.54.0 (5ae8d74b3 2021-06-22)
/app/diesel_demo # rustc -V
rustc 1.54.0 (a178d0322 2021-07-26)

/app/diesel_demo # diesel setup
Segmentation fault
/app/diesel_demo # diesel migration generate create_posts
Creating migrations/2021-08-07-020132_create_posts/up.sql
Creating migrations/2021-08-07-020132_create_posts/down.sql

/app/diesel_demo # diesel migration run
Segmentation fault

An error occurred in installing diesel_cli occur

when I run cargo install diesel_cli

toolchain = stable-x86_64-pc-windows-gnu
gcc-v = gcc version 8.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project)

note that when compile diesel_cli
note: D:/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lsqlite3 D:/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lpq D:/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmysql collect2.exe: error: ld returned 1 exit status

returning_clauses_for_sqlite_3_35 flag not working

it seems like with sqlite diesel traits its not queryable but execute work fine with my conn.
Screenshot 2023-04-26 at 7 32 40 PM

 let now = Utc::now().to_string();
            let ne = NewEmployee {
                name: &meta["Employee First Name and Last Name"].to_string().replace("\"", ""),
                department: &"",
                software_ids: &"",
                created_on: &now,
                created_by:  & "ab-system",
                updated_on: &now,
                updated_by:  & "ab-system",
            };


         diesel::insert_into(employee::table)
                .values(ne)
                .execute(conn)
                .expect("Error saving new requestor");
        
         // Get the ID of the last inserted row
         let result = employee::dsl::employee.filter(updated_on.eq(now))
         .get_result::<Employee>(conn).unwrap()   <<<==== Here conn showing the above error
     

println!("{:#?}", result);

the traits are in order while insert_into.

Guide for application testing with diesel

Hi there,

I really like the guides you already have. I'd really like to see a guide on how to correctly run tests (ie #[cfg(test)] mod tests) or integrations tests with diesel to correctly do migrations, fixtures, and teardown. I don't see any resources about this today, but I think it would really help consumers of the library so there is "best way" to achieve this.

Thanks,

Update the "Composing applications with diesel" guide to diesel 2.0

As preparation of the upcoming diesel 2.0 release we need to update the guides on our web page to reflect the corresponding changes.
For the "Composing Applications with Diesel" guide this involves the following points:

  1. Update any code snippet to diesel 2.0. Unfortunately most of them directly link to the crates.io code, so a "real" update is required here
  2. Remove the links to the crates.io source code, as they use diesel 1.4.x currently. Hopefully we can add them back as soon as they've updated their code.
  3. Update any documentation link to point to the corresponding 2.0.x documentation page
  4. Open a PR with all this changes targeting the diesel_2.0_update branch

Please use this issue as discussion platform to ask any question that is unclear about updating this guide.

The Getting Started Guide should have an example for getting single item

Hey there!

I am learning Rust and I am trying to create my own api based on actix-web and diesel-orm. I was going through Getting started guide and while it had great examples for CRUD, it's missing an implementation for getting a single item from the database. I managed to find out how to do that in the end but it took me a while.

Mention table! and diesel print-schema in the guide

It seems that many people are afraid of automatic schema inference. While we shouldn't change the guide to not use infer_schema!, we should probably mention in an info block that people can also use the table! macro and diesel print-schema on the CLI.

Update the "Configuring diesel cli" guide to diesel 2.0

As preparation of the upcoming diesel 2.0 release we need to update the guides on our web page to reflect the corresponding changes.
For the "Configuring diesel cli" guide this involves the following points:

  1. Add a section about the newly added generate_missing_sql_type_definitions option. This options allows users to control if diesel cli should generate sql type definitions for unknown types or not. This feature is currently only available for the postgres backend.
  2. Update the section about patch files to remove the requirement to have a patch binary installed. Diesel cli now uses a built-in way to patch files.
  3. Test that everything else still works with the diesel cli 2.0 prerelease.
  4. Open a PR with all this changes targeting the diesel_2.0_update branch

Please use this issue as discussion platform to ask any question that is unclear about updating this guide.

Broken link in Getting Started Guide

The link to dotenv in the Getting Started Guide:

[dotenv-rust]: https://github.com/slapresta/rust-dotenv

Returns a 404.

The dotenv docs might be a better place to point.

Note that the dotenv docs point to https://github.com/purpliminal/rust-dotenv/, which is currently intentionally empty (purpliminal/rust-dotenv#1), so pointing to the docs.rs may be a good solution until a GitHub repo is finalized.

QueryBuilder should be QueryFragment?

image

Looking at the image above I noticed that the examples are all talking about implementing the QueryFragment trait but the text after mentions QueryBuilder which is not mentioned anywhere else in the guide. Should QueryBuilder actually be QueryFragment?

Batch insert example in the "All about inserts" guide renders incorrectly

screen shot 2017-12-24 at 12 12 14 pm

The main issue is the line:

let user_form = serde_json::from_str::>(json)?;

which should actually be:

let user_form = serde_json::from_str::<Vec<UserForm>>(json)?;

As per this. Not sure if this falls under the umbrella of #47 but wanted to note it here. I'm not too familiar with slim and I don't see anything obviously wrong with https://github.com/sgrif/diesel.rs-website/blob/master/source/views/guides/all-about-inserts.html.slim#L417 but perhaps I'm missing something obvious.

Looking at the rendered html it looks like <Vec<UserForm> portion of the type is being rendered as html:

screen shot 2017-12-24 at 12 20 24 pm

Footer outdated

The footer is somewhat 'outdated', it reads at the moment: Copyright © 2015-2022 The Diesel Core Team.

I will file a PR with an update to change 2022 to 2023. Edit: filed as #185

Wasteful margins on https://diesel.rs/guides/getting-started

First, thanks for creating this excellent tutorial.

As I only have a single screen, I put the IDE on the left and this web page on the right.

As you narrow the browser window, to give more space in the IDE, the text column becomes narrower while wasting large margins at the sides.

It would be good if the wide margins were the first thing to go when making the page less than 1000px wide. (These margins are completely empty apart from the Diesel logo and two links at the top of the page, which could move inward at < 1000px as there is nothing in the centre.)

Format wast view screen real estate

On screens such as Composing Applications with Diesel, the HTML class, guide-wrapper, should not have its width and margin-left CSS properties set to any values. The region should be allowed to fill it container as that already provides sufficient padding. Currently, guide-wrapper wast 2/3 of the width, annoyingly clipping the source code examples.

Community projects

Hey! Georg asked me to create a PR/issue for dsync here.

I tried to find a place on the website where a list of community projects might go but all I can think of is another section on the guides page. Let me know, and I can create a PR!

Issues building site with fresh repository clone on MacOS

Hey there,

Submitted a pull request here: #165, but getting the site built wasn't as straightforward as the README currently suggests.

The first of my issues is that running make page results in the following error:
ModuleNotFoundError: No module named 'pandocfilters'. What the README does not inform would-be contributors of is that the following prerequisites need to be met:

  • Python is installed
  • The pandocfilters module is installed globally

I would suggest updating the README to let people know Python is required and subsequently looking into virtual environments to both version control the list of necessary packages, and enable modifying the Makefile to instantiate the virtual environment before running the page target.

I am assuming development has only happened on Linux machines, as after fixing the pandocfilters issue, running make page results in the following error:

cp assets/ out -r
cp: -r is not a directory

from this line in Makefile.

cp seems to behave differently on BSD/MacOS or something. I had to change the command to the following for the build to succeed:

cp -R assets out

So making sure this is a cross-platform compatible operation would be helpful. I believe this variation on the command works on both MacOS and Linux.

Resp. design too tight around 1000px width

I follow the tutorials on a vertical screen, my firefox window is 1000px wide and the result is frustrating :

Screenshot from 2020-06-11 14-28-54

Under 850 px those margins disapear, which means we're better off reducing the window's width to see more text.

I'm very grateful for diesel, I'd be even more if that were fixed.

Feature Request: impl<'a, Parent, Child> BelongingToDsl<(&'a [Parent], &'a [Parent])> for Child

I authored stack-queue specifically so that I could create a data loader that integrates with Diesel. The current design only batches contiguous slices and simply starts a new batch whenever a task batch would otherwise wrap around to the beginning, however I could make this support wrap-around batching by returning an ordered pair of slices instead. The only way I could make this work and still integrate with BelongingToDsl without creating an intermediary Vec would be for BelongingToDsl to impl<'a, Parent, Child> BelongingToDsl<(&'a [Parent], &'a [Parent])> for Child

Update the "All about inserts" guide to diesel 2.0

As preparation of the upcoming diesel 2.0 release we need to update the guides on our web page to reflect the corresponding changes.
For the "All about inserts" guide this involves the following points:

  1. Update any code snippet to the corresponding variant from the 2.0.x branch
  2. Update any link pointing to the corresponding example in our repository to point to the 2.0.x branch
  3. Update any documentation link to point to the corresponding 2.0.x documentation page
  4. Update the section about RETURNING so that it mentions that support for RETURNING clauses using the sqlite backend is behind a feature flag (returning_clauses_for_sqlite_3_35)
  5. Update the wording in the section about UPSERT so that it applies to the SQLite backend as well.
  6. Open a PR with all this changes targeting the diesel_2.0_update branch

Please use this issue as discussion platform to ask any question that is unclear about updating this guide.

Adding code snippets for each database in Getting Started document

The Getting Started Guid is a great resource when getting started with Diesel. It goes though all of the basics quickly and clearly. Unfortunately, it's only written for PostgreSQL.

I'm not a professional programmer, I'm more of a weekend hobbyist. So this is more from a novices' stand point rather than a professional's. I think the best kinds of getting started guide or an introduction guide should use the simplest of technologies to get the a new user up and running with the least amount of friction. Using PostgreSQL doesn't fulfill that requirement. The user has to install PostgreSQL database, configure it, and run the server before even beginning the guide. The guide should focus on the simplest of technologies by default at least, which in this case, would be SQLite.

Although this might not seem like a big deal at first glance -- superficially it might seem simple enough for the reader to replace postgress with the database technology they would like to use -- there's quite a number of issues that pops up where the solution is not obvious.

Examples

up.sql

CREATE TABLE posts (
  id SERIAL PRIMARY KEY,
  title VARCHAR NOT NULL,
  body TEXT NOT NULL,
  published BOOLEAN NOT NULL DEFAULT 'f'
)

SQLite doesn't support some of the types used in PostgreSQL:

  • SERIAL
  • VARCHAR
  • BOOLEAN

This might be obvious to someone who works with SQLite but can be a source of frustration for someone planning to use SQLite for the first time.

Here's an example of a YouTuber explaining how to go about making changes to this example so it would work for SQLite.

src/lib.rs

#[macro_use]
extern crate diesel;
extern crate dotenv;

use diesel::prelude::*;
use diesel::pg::PgConnection;
use dotenv::dotenv;
use std::env;

pub fn establish_connection() -> PgConnection {
    dotenv().ok();

    let database_url = env::var("DATABASE_URL")
        .expect("DATABASE_URL must be set");
    PgConnection::establish(&database_url)
        .expect(&format!("Error connecting to {}", database_url))
}

Here the connector is made with diesel::pg::PgConnection;. An astute reader will most likely realize that the use diesel::pg contains methods for connecting to a PostgreSQL database. The reader would have to resort to reading the documentation to fix this line. Not the end of the world, and some might say that reading the manual is a good thing, but this is a Getting Started guide which should be a tutorial with the least amount of friction possible.

Here's an example of a YouTuber explaining how to go about making changes to this example so it would work for SQLite.

src/models.rs

#[derive(Queryable)]
pub struct Post {
    pub id: i32,
    pub title: String,
    pub body: String,
    pub published: bool,
}

Same as the up.sql example, SQLite does not support bool types.

src/lib.rs

use self::models::{Post, NewPost};

pub fn create_post<'a>(conn: &PgConnection, title: &'a str, body: &'a str) -> Post {
    use schema::posts;

    let new_post = NewPost {
        title: title,
        body: body,
    };

    diesel::insert_into(posts::table)
        .values(&new_post)
        .get_result(conn)
        .expect("Error saving new post")
}

The pub fn create_post<'a>(conn: &PgConnection, title: &'a str, body: &'a str) -> Post { has to changed. Another problem is .get_result(conn) which is not implemented for SQLite. This is not obvious. Achieving the same reuslt as this line is also not obvious.

image

A YouTuber explaining the problem.

These are only some of the firction when using the Getting Started Guid for a database technology other than PostgreSQL.

Solution

The solution is to have the same tutorial but with the snippets translated for each database supported by Diesel. This would also mean that the body of the guide has to be worded in a way that applies to all databases and when the details diverge, add a note box for the specific database.

Here's a mock-up of how the snippets can be toggled for each database.
desil-example

Here's a mock-up of how special notes for the databases can be implemented.
diesel-box

Another way to achieve the same thing without coding a dynamic page would be to write a separate Getting Stated Guide with <name_of_database> guide for each database.

Thank you all for a fantastic library!

Nit: The diesel logo shows a red fuel can.

Diesel is stored in yellow containers so you can tell them apart from other fuels (red for gas, blue for kerosene, etc.).

In many areas of the world, it is illegal for a fuel station attendant to (re)fill fuel into the wrong-colored container for safety (and interoperability) reasons.

Typo in migration file name

In Relations topic, "many-to-many or m:n" section, the "down" migration file for books_authors table (DROP TABLE books_authors;) should be renamed as down.sql instead of up.sql.

Transfer repo to diesel-rs

It would be nice to have this repo in the diesel-rs organization next to the rest of the diesel repositories. Currently it takes a little bit of searching to find out where the diesel.rs website repo actually is.

Update the "Extending diesel" guide to diesel 2.0

As preparation of the upcoming diesel 2.0 release we need to update the guides on our web page to reflect the corresponding changes.
For the "Extending diesel" guide this involves the following points:

  1. Update any code snippet to the corresponding variant from the 2.0.x branch
  2. Update any link pointing to the corresponding example in our repository to point to the 2.0.x branch
  3. Update any documentation link to point to the corresponding 2.0.x documentation page
  4. Update any mention of diesel_*operator! macros to use the non-deprecated diesel::*_operator! variant.
  5. Open a PR with all this changes targeting the diesel_2.0_update branch

Please use this issue as discussion platform to ask any question that is unclear about updating this guide.

Improve website by telling what the project is about

I just saw a link for the Diesel website on lobste.rs, followed the link to the website, yet there is absolutely no information on the frontpage about what Diesel is, neither an about page, so I am left guessing looking at features.

I highly recommend that the first thing a persons sees, when visiting your website, is a clear cut message describing what Diesel is.

Just as an inspiration, take a look at https://www.postgresql.org/ or https://www.sqlite.org/ or https://www.openbsd.org/.

Text readability

The white text on the light blue background is quite hard to read, especially since the text is so free floating on the page.

I've played around a bit and I'd suggest giving the content area a bit of a padding and a backgroudn color.

something like:

.guide-wrapper {
    margin-right: 0;
    padding: 20px 30px;
    background: #3e4d66;
    border-radius: 10px;
}

This would also require makign .guide-wrapper a bit larger in the @media css.

@media screen and (min-width: 53.75em) {
  .guide-wrapper {
      width: 70%
  }
  
}
...

@corwinharrell

Getting started guide could be more specific.

When running $ cargo install diesel_cli on a Debian 9 machine I was getting:

= note: /usr/bin/ld: cannot find -lsqlite3
          /usr/bin/ld: cannot find -lpq
          /usr/bin/ld: cannot find -lmysqlclient
          collect2: error: ld returned 1 exit status

It might be useful if the guide mentioned what command to run to solve these issues, instead of "You can resolve this issue by either installing the library (using the usual way to do this depending on your operating system)".

In my case the issue was resolved by installing the following:

sudo apt install libpq-dev libmysqlclient-dev libsqlite3-dev

Could we consider migrating to mdbook?

The website is built with middleman but its version is too old and we don't familiar with it. That makes it difficult to maintain (e.g. #106). Could we consider migrating to mdbook (or something else, which is easy to maintain) to make it easier?
cc @weiznich

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.